docker study summary (four)

1. After installation Docker ToolBox, open Docker Quickstart Terminal, then the default is that the connection (Oracle VM VirtualBox) default,

The need to connect additional docker, can use the command docker-machine ssh docker-name

2. The need to create new docker can perform docker-machine create --driver virtualbox docker-name in git Bash, do docker-machine ls can view the list of docker.

3.Swarm Cluster Management

Docker is a swarm of cluster management tools can be run using swarm in the container program extended to all nodes.

swarm consists of a cluster management node (manager) and worker nodes (work node).

Next, we create a swarm manager, three work node, in git bash (installed by default when you install toolbox) execute the following command:

docker-machine create -d virtualbox swarm-manager

docker-machine create -d virtualbox swarm-worker1

docker-machine create -d virtualbox swarm-worker2

docker-machine create -d virtualbox swarm-worker3

After creating each node, manager needs to be initialized, execution docker-machine ssh swarm-manager login, and then perform docker swarm init --advertise-addr 192.168.99.106, as shown above represents the successful initialization. Then work node join swarm cluster, one by one to log in to each work node to perform the above figure docker swarm join --token XXXX.

完成以上步骤后,执行docker info,可以看到Managers1个,Nodes共有4个(3个work node,1个manager)。

在swarm-manager上执行docker service create --replicas 1 --name redis redis,在集群中创建一个Redis服务,可以看到该服务被随机分配在swarm-worker1上。

 执行docker service inspect --pretty redis可以查看其详细信息。

 

在manager端执行docker service scale redis=n 可以将Redis服务进行扩展,如执行docker service scale redis=3,之后查看redis服务可以发现已经有三个在运行,分别运行在swarm-worker1、swarm-worker2、swarm-manager上。

需要停止删除服务、停止node、删除node可以使用以下命令。

docker service rm service-name

docker-machine stop docker-name

socker-machine rm docker-name

 

 

 

 

 

 

 

 

 

 

 

发布了137 篇原创文章 · 获赞 14 · 访问量 6万+

Guess you like

Origin blog.csdn.net/haiziccc/article/details/104363303