使用docker --link to mysql [英] using docker --link to mysql
本文介绍了使用docker --link to mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要能够连接到te next docker db:
I need to be able to connect to te next docker db:
sudo docker run --name=cmydatabse -v /opt/mysql_data:/var/lib/mysql --env="MYSQL_ROOT_PASSWORD=mypassword" mysql:5.7
使用链接命令,我想创建一个链接,这样我就可以使用以下命令连接到这个数据库:
using a link command, I want to create a link so I can connect to this database using:
mysql -u -p -h Something P:3306
这可能吗?
推荐答案
链接是docker compose 2和所有最近的docker版本的遗产。
Links are legacy from docker compose 2 and all recent docker versions.
链接mysql容器的方法正在使用网络 https://docs.docker.com/engine/ userguide / networking / #user-defined-networks 。
The way to link your mysql container is using networks https://docs.docker.com/engine/userguide/networking/#user-defined-networks.
通过网络,容器将通过容器名称相互识别
With a network the containers will recognize each other by the container name
这篇关于使用docker --link to mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文