Skip to content

Docker:Swarm

Current versions of Docker include swarm mode for natively managing a cluster of Docker Engines called a swarm. Use the Docker CLI to create a swarm, deploy application services to a swarm, and manage swarm behavior.

Display and rotate the root CA

$ docker swarm ca

만약 스웜이 초기화되지 않았다면 다음과 같은 메시지가 출력된다.

Error response from daemon: This node is not a swarm manager. Use "docker swarm init" or "docker swarm join" to connect this node to swarm and try again.

초기화(docker swarm init 하거나 스웜에 참여docker swarm join해야 한다.

Initialize a swarm

$ docker swarm init

초기화에 성공하면 다음과 같이 출력된다.

Swarm initialized: current node (4mu50fuj9paosdcor6sjsi4bp) is now a manager.

To add a worker to this swarm, run the following command:

    docker swarm join --token SWMTKN-1-67muwgaig1jyfnpzmyn2yj55o2fcxx1awlrta28ssgwgf9v25i-aal0nt4ytluxowo8g70malidi 192.168.70.21:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.

스웜에 참여하고 싶은 PC에서 위에 출력된 docker swarm join ... 명령을 복사하고 실행하면 된다.

docker swarm join --token SWMTKN-1-67muwgaig1jyfnpzmyn2yj55o2fcxx1awlrta28ssgwgf9v25i-aal0nt4ytluxowo8g70malidi 192.168.70.21:2377
$ docker swarm init --advertise-addr 0.0.0.0:9999

Join a swarm as a node and/or manager

docker swarm join --token SWMTKN-1-67muwgaig1jyfnpzmyn2yj55o2fcxx1awlrta28ssgwgf9v25i-aal0nt4ytluxowo8g70malidi 192.168.70.21:2377

Leave the swarm

docker swarm leave

Swarm 에서 노드를 선택하는 방법

Take a look at the Swarm filter docs. You can set various constraints on what node Swarm should pick for any given container. For your case try something like:

docker run ... -e constraint:node==node1 ...

This would start the container on node1.

Docker Swarm 구성 확인

docker node ls

Container orchestration

Tools

See also

Favorite site

Guide

References


  1. Container-orchestration-with-docker-swarm.pdf 

  2. Zero-downtime-docker-deployment.pdf 

  3. Sauru.so_-_getting-started-with-docker-swarm.pdf 

  4. Sauru.so_-_high-availability-of-docker-swarm.pdf 

  5. Sauru.so_-_run-a-service-on-docker-swarm.pdf 

  6. Sauru.so_-_little-more-about-docker-swarm.pdf