Do we need to transfer docker-compose.yml to Production server?

大城市里の小女人 提交于 2020-06-17 16:48:19

问题


I'm pretty new to docker and docker compose. I have managed to build my image and push it to Docker Hub. The app I built is simple and consists of 2 images php7-apache and mysql offical images. All declared in docker-compose.yml.

I informed my team to pull the image I built from my Docker Hub repository using docker pull ... and start it using docker run -d .... But when we run docker ps in the production server, only 1 process is running but no MySQL.

Usually, when I run locally using docker-compose up I get this in the terminal: Creating network "myntrelease_default" with the default driver Creating myntrelease_mysql_1 Creating myntrelease_laravel_1 I can then access the MySql using docker-compose exec mysql bash and tweak some tables there. So far so good.

Question is how can I use docker-compose.yml in the production server when it's not available because its in the image itself?


回答1:


Short answer: Yes, you need the docker-compose.yml in the production environment.

Explanation: Every image is independent. Since your image is independent of MySQL image (at least that's what I understand from your questions), and docker-compose.yml defines the relationship between the two (eg. how MySQL is accessible in the php7-apache image), then you definitely need the docker-compose.yml in production. Even if you only have a single image its usually good to use docker-compose.yml so that settings and configuration like volume mounts, ports etc. can be clearly defined.



来源:https://stackoverflow.com/questions/49649192/do-we-need-to-transfer-docker-compose-yml-to-production-server

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