将mysql链接到docker中的应用程序 [英] Link mysql to application in docker
问题描述
我如何将mysql容器连接到另一个容器,以便其中一个容器中的应用程序可以使用Mysql?基于此
-名称some-app
指的是您要分配给正在运行的容器的容器名称。
application-that-uses-mysql
是指您正在使用的图像。该图像需要 mysql
,并且您已通过使用命令将myqsl连接到该图像–链接some-mysql:mysql
但是,链接已被弃用,但您仍然可以使用网络连接到其他容器。 此处的答案应该能够帮助您设置连接。
编辑:删除重复项并提供完整答案。
Hi how would I connect a mysql container to another container so that my application in one of those container can use Mysql? Based on this reference I need to run this
docker run --name some-app --link some-mysql:mysql -d application-that-uses-mysql
But I have no idea what does some-app mean and the application-that-uses-mysql? does it mean the container ID that will use it? below is the list of the running container
--name some-app
refers to the container name you want to assign to the container you are running.
application-that-uses-mysql
refers to the image which you are using. This image requires mysql
and you have connecte myqsl to this image by using the command --link some-mysql:mysql
.
However, Links are deprecated but you still can connect to other containers using networks. An answer here should be able to help you out in setting the connections.
Edit: Removed duplicate and provided complete answer.
这篇关于将mysql链接到docker中的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!