如何在不同的机器上运行 docker 容器 [英] How to run docker containers on different machines
问题描述
我为我的应用程序设置了几个 docker 容器:
- mysql 的容器
- 应用服务器容器(tomcat7)
- nginx 容器
- python tornado 应用程序的容器
在我的本地机器上,使用 docker-machine
,我已经尝试了所有这些容器并且它们彼此交互.我使用 boot2linux 创建了一台虚拟机,并在其上设置了所有这些容器.
现在,对于生产,我将在单独的服务器上运行这些容器中的每一个.docker 有什么东西可以快速/轻松地做到这一点吗?或者我应该在每台服务器上设置 docker,将相关图像复制到该服务器,然后在所有服务器上手动启动 docker-images?
或者我应该在每台服务器上设置 docker,将相关图像复制到该服务器,然后在所有服务器上手动启动 docker-images?
是的,但您还应该:
- 创建
然后你可以在你的机器上创建你的容器.
I've setup several docker containers for my application:
- container for mysql
- container for application server (tomcat7)
- container for nginx
- 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?
解决方案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
这篇关于如何在不同的机器上运行 docker 容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!