This post shows us how we connect to MySQL container from the host OS. I am using Mac OS and running vagrant. In vagrant box, I have a MySQL container running so I will connect to it from Mac OS.

MySQL container

Run commands below while you are in vagrant box so that we get the IP address of the container.

$ docker-compose ps
Name Command State Ports
app_mysql_1 mysqld Up>3306/tcp

$ echo $(docker inspect app_mysql_1 | grep IPAddress | grep -o -E '[0-9\.]+')

Sequel Pro

Create a new SSH connection and use values below. That's it!

MySQL Host:
Username: root
Password: root
SSH Host: # Vagrant IP
SSH User: vagrant # Vagrant user
SSH Key: .vagrant/machines/machine/virtualbox/private_key # Vagrant box's key