Docker-swarm

Aus xinux wiki
Wechseln zu: Navigation, Suche

install

change host file

/etc/hosts
10.50.66.21 node01
10.50.66.22 node02 
10.50.66.23 node03

create swarm

node01

swarm init

  • docker swarm init --advertise-addr 10.50.66.21
node02
  • docker swarm join --token XXXXXXXXXX
  • docker swarm promote node0
node03
  • docker swarm join --token XXXXXXXXXX

docker stack

  • vi docker-compose.yml
version: "3.5"
services:
  web:
    image: containous/whoami
    ports:
      - "80:80"
    #    networks:
    #      - ext
    deploy:
      mode: replicated # replicate container on other swarm nodes
      replicas: 3 #number of replicas
      labels:
        - traefik.enable=true
        - traefik.port=80
        #- traefik.frontend.rule=Host:whoami.bonis.info
        #- traefik.frontend.rule=Host:whoami.dsgvo-europa.com
        - traefik.frontend.rule=Host:whoami.2meet.de
        - traefik.frontend.passHostHeader=true
        #- traefik.frontend.rule=Host:whoami.cloudraiser.net
        - traefik.protocol=http
  • docker stack deploy -c docker-stack.yml $(basename $PWD)
  • docker service ls
ID                  NAME                MODE                REPLICAS            IMAGE                      PORTS
wz126t6z1puo        whoami_web          replicated          3/3                 containous/whoami:latest   *:80->80/tcp

links