简体   繁体   English

如何创建到dockerfile / mysql容器的ssh隧道

[英]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. 我正在寻找用于创建SSH隧道(在非标准端口上,例如3309)的正确语法,我可以在Mac OS X Yosemite终端上使用它,这将使我能够使用Sequel Pro连接到mysql容器在boot2docker中运行。

For example, I tried this, 例如,我试过这个,

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

but it asks for docker@192.168.59.103's password and I don't think that is needed so I'm assuming that's not quite right. 但它要求提供docker@192.168.59.103的密码,我不认为这是必要的,所以我认为这不太对。

Thanks! 谢谢!

If you don't want to tunnel into docker, you can just setup a ssh connection through Sequel pro 如果您不想隧道进入docker,可以通过Sequel pro设置ssh连接

Create a new connection in Sequel pro and choose the SSH connection option and follow the instructions below to populate the fields. 在Sequel pro中创建一个新连接,然后选择SSH连接选项并按照以下说明填充字段。

Mysql Host: Mysql主机:

Issue the command below to get your mysql host 发出以下命令来获取mysql主机

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. 如果您不知道容器ID或名称,请执行docker ps -a ,并从输出中找到id或name。

Username, password, database (the db credentials) 用户名,密码,数据库(数据库凭证)

SSH Host SSH主机

Enter boot2docker ip in your terminal to get the host 在终端中输入boot2docker ip以获取主机

SSH User SSH用户

docker 搬运工人

SSH Password SSH密码

tcuser tcuser

Test your connection and after it is successful, save it to your favorites! 测试您的连接,并在成功后将其保存到您的收藏夹!

这可能不是您正在寻找的,但docker密码是tcuser (标准默认值),它可以让您进入boot2docker主机。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM