Docker-swarm: Unterschied zwischen den Versionen

Aus xinux wiki
Wechseln zu: Navigation, Suche
(node01 node02 node03)
(docker stack)
Zeile 25: Zeile 25:
  
 
==docker stack==
 
==docker stack==
*vi docker-compose.yaml
+
*vi docker-compose.yml
 
<pre>
 
<pre>
 
version: "3.5"
 
version: "3.5"
Zeile 48: Zeile 48:
 
         - traefik.protocol=http
 
         - traefik.protocol=http
 
</pre>
 
</pre>
 +
*docker stack deploy -c docker-stack.yml $(basename $PWD)
  
 
*docker service ls
 
*docker service ls

Version vom 25. März 2020, 15:47 Uhr

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