using docker --link to mysql

和自甴很熟 提交于 2019-12-11 06:34:50

问题


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

Is this possible?


回答1:


Links are legacy from docker compose 2 and all recent docker versions.

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



来源:https://stackoverflow.com/questions/47023257/using-docker-link-to-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!