您的位置:首页 > 运维架构 > Docker

Docker Machine, Compose, and Swarm: How They Work Together

2015-12-08 17:27 736 查看
The three tools are now neatly packaged into what’s called the Docker Toolbox.

Docker Machine
1/ create Linux VM
docker-machine create --driver virtualbox containerhost
or
docker-machine create -d virtualbox local
2/ open docker vm's interface
eval "$(docker-machine env local)"
or
boot2docker shellinit

3/ stop vm
docker-machine stop containerhost
4/ remove vm
docker-machine rm containerhost

Docker Compose
1/ compose docker-compose.yml in repository directory
2/ docker-compose up

Docker Swarm
1/ generate “discovery token”(in vm)
docker run swarm create
# The discovery token is actually created using Docker’s public discovery service.

2/ create Swarm Master(in host machine)
docker-machine create -d virtualbox --swarm --swarm-master --swarm-discovery token://YOURTOKENHERE swarm-master

3/ create Swarm nodes(in host machine)
docker-machine create -d virtualbox --swarm --swarm-discovery token://YOURTOKENHERE swarm-agent-00
docker-machine create -d virtualbox --swarm --swarm-discovery token://YOURTOKENHERE swarm-agent-01

4/ shut down and remove 'local'

5/ open Swarm Master shell
eval $(docker-machine env --swarm swarm-master)
# Now we have a Swarm Master and two Swarm Nodes running locally,use 'docker info' to check

6/ run containers on cluster node
docker run -d redis
# 0d7af2492be35cc9c7593f6d677185c6c44f3a06898258585c7d2d2f9aa03c2e
docker run -d nginx
# 0babf055abf9b487b6bafd4651386075f8d6f46ce9f192849bc32345997438ea

7/ list the containers scheduled on different clustered
docker ps
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: