Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create ssh tunnel to dockerfile/mysql container

I am looking for the right syntax to use to create an SSH tunnel (on a non-standard port, eg 3309) that I can use from Mac OS X Yosemite terminal, which will enable me to use Sequel Pro to connect to the mysql container running inside boot2docker.

For example, I tried this,

ssh -L3309:localhost:3306 docker@$(boot2docker ip)

but it asks for [email protected]'s password and I don't think that is needed so I'm assuming that's not quite right.

Thanks!

like image 270
phpguru Avatar asked Mar 03 '15 16:03

phpguru


1 Answers

If you don't want to tunnel into docker, you can just setup a ssh connection through Sequel pro

Create a new connection in Sequel pro and choose the SSH connection option and follow the instructions below to populate the fields.

Mysql Host:

Issue the command below to get your mysql host

docker inspect --format='{{.NetworkSettings.IPAddress}}' "container id or container name"

If you don't know your container id or name, do docker ps -a, and locate the id or name from the output.

Username, password, database (the db credentials)

SSH Host

Enter boot2docker ip in your terminal to get the host

SSH User

docker

SSH Password

tcuser

Test your connection and after it is successful, save it to your favorites!

like image 155
cawhite78 Avatar answered Oct 12 '22 23:10

cawhite78