2.Docker_Swarm_Commands
2.Docker_Swarm_Commands
6. Container Placement.
● Service Constraint:
● docker service create --constraint=node.role==manager nginx
● docker service create --constraint=node.role!=worker nginx
● node.<label>=custom label
● node.role=inbuult label
● docker node update --label-add=dmz=true node2
● docker service create --constraint=node.labels.dmz==true nginx
Default Labels:
https://blog.programster.org/using-traefik-with-docker-swarm-for-deploying-web-
applications
NODE AVAILABILITY:
================
docker node update --availability pause node5 - Dont accept new tasks , runs existing.
docker node update --availability active node5
docker node update --availability drain node5 - Reschedule talsks
Resource Requirements:
====================
Limits: max
Reservations: min
docker service create --name LIMITTEST --limit-cpu .25 --limit-memory 100M --replicas 3
--publish 3000:80 sreeharshav/rollingupdate:v3
STRESS Dockerfile:
================
FROM debian:latest
RUN apt-get update && apt-get install -y stress \
--no-install-recommends && rm -r /var/lib/apt/lists/*
Container Healthchecks:
====================
Docker container healthchecks
https://blog.sixeyed.com/docker-healthchecks-why-not-to-use-curl-or-iwr/
=======================================================================
===
https://docs.docker.com/engine/reference/commandline/events/
=====================================================================
DOCKER CONFIG:
docker config create nginxindex1 index.html
OLD-PIC:
NEW-PIC:
https://linuxize.com/post/how-to-install-jenkins-on-ubuntu-18-04/
nano /lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H unix:// -H tcp://0.0.0.0:2375
systemctl daemon-reload
systemctl restart docker
sudo nohup docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock &
sudo usermod -a -G root jenkins
usermod -a -G docker jenkins