How to run docker containers on different machines

怎甘沉沦 提交于 2020-01-01 19:23:33

问题


I've setup several docker containers for my application:

  1. container for mysql
  2. container for application server (tomcat7)
  3. container for nginx
  4. container for python tornado application

On my local machine, using docker-machine, I've tried all these containers and them interactive with each other. I created one virtualbox machine with boot2linux and setup all these containers on it.

Now, for production I am going to run each one of these containers on a separate server. Is there something docker provides to quickly/easily do this? Or should I set up docker on each server, copy relevant images to that server, and then start docker-images manually on all servers?


回答1:


Or should I set up docker on each server, copy relevant images to that server, and then start docker-images manually on all servers?

Yes, but you should also:

  • create the relevant libnetworks in order for your containers to be registered in them
  • create as first container a KV one (Key-Value: Consul, etcd, Zookeeper, ...) that will monitor each containers in each network(/machine), allowing them to see each others.
    Note: you might want to use a docker 1.10 for adding a network-scoped alias to your containers.

Then you can create your containers on your machines.

See a practical example at Understand Docker container networks



来源:https://stackoverflow.com/questions/34938674/how-to-run-docker-containers-on-different-machines

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