Link mysql to application in docker

我只是一个虾纸丫 提交于 2019-12-24 01:23:10

问题


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


回答1:


--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.




回答2:


--name some-app gives the newly started container the name some-app.

--link some-mysql:mysql links the container with name some-mysql (this is the one running MySQL) to the new container so that it can be accessed as mysqlwithin the container.

application-that-uses-mysqlis the name of the image containing your app.

If you are unsure about the meaning of some parameters, there is always the documentation.



来源:https://stackoverflow.com/questions/45156912/link-mysql-to-application-in-docker

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