2022-01-18 – Swimming
Quite fast for me this time, especially the first 50 meters, less than 1 minute should be my record. I also completed 1700m, because the swimming pool opened 3 minutes earlier.
The default network driver. Needs to map the port to host in order to access port of container.
Removes network isolation between the container and the Docker host, and uses the host's networking directly. So the containers can not have port conflicting with other containers and also host.
The IP will be the same as host.
Disables all networking for containers. Usually used in conjunction with a custom network drive.
Connect multiple Docker daemons together and enable swarm services to communicate with each other daemons.
Using this overlay network, the container on different hosts can communicate with each other.
Allow you to assign a MAC address to a container, making it appears as a physical device on the network. The Docker daemon routes traffic to container by their MAC addresses.
This allows container has different IP address on the host network.
Veritas Cluster configuration document.
Veritas Cluster Cheat sheet
VCS cheat sheet -complete
Veritas Cluster Cheat sheet (Cache)
Recently, I got such error quite often when using google reCaptcha v3. To allow me login without reCaptcha verification, login to WordPress server, and rename plugin folder advanced-nocaptcha-recaptcha
, then login normally. After login, rename back the folder.
docker container prune
docker stop $(docker ps -q)
docker container ls -a
docker container prune -f
docker --rm ...
docker swarm
docker image ls
docker image prune -f
docker network ls
docker network prune -f
docker volume ls
docker volume prune -f
docker system prune
docker system prune --volumes
docker system prune --volumes --all
docker system prune --volumes --help
server.js
const express = require("express");
const os = require("os");
const app = express();
app.get("/", (req, res) => {
res.send("Hello from Swarm " + os.hostname());
});
app.listen(3000, () => {
console.log("Server is running on port 3000");
});
Dockerfile
FROM node:11.1.0-alpine
WORKDIR /home/node
COPY . .
RUN npm install
CMD npm start
docker-compose.yml
version: "3"
services:
web:
build: .
image: takacsmark/swarm-example:1.0
ports:
- 80:3000
networks:
- mynet
deploy:
replicas: 6
update_config:
parallelism: 2
delay: 10s
restart_policy:
condition: on-failure
visualizer:
image: dockersamples/visualizer:stable
ports:
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
deploy:
placement:
constraints: [node.role == manager]
networks:
mynet:
requirements.txt
flash
redis
docker swarm init
docker swarm init --advertise-addr eth1
docker swarm join ...
docker swarm leave -f
docker demote
docker promote
docker stack ls
docker stack ps
docker service ls
docker service ps
docker service create
To run a service in all nodes
docker service create --name 'service_name' -p 8000:8000 --mode global demoapp
To run a server in 3 nodes
docker service create --name 'service_name' -p 8000:8000 --replicas 2 demoapp
It is scheduling the container, which is managed using docker service
command.
docker service ps nodeapp_web
The containers should be managed using swarm commands, but they also can be seen using container command.
docker ps
docker kill
docker stack deploy -c docker-compose.yml nodeapp
This will create network nodeapp_mynet
, and two services (nodeapp_web
and nodeapp_db
)
Note: The images need to be pre-built using docker-compose build
command, and push into docker hub.
docker stack ls
docker service ls
docker stack services ls
docker service scale nodeapp_web=4
To access all 4 services, just need to access http://localhost, then the 4 services will be supporting same port on localhost.
Note: The hostname appeared in http://localhost is changing
docker network create -d overlay myoverlay1
docker service create --name webapp1 -d --network myoverlay1 -p 8001:80 test/webapp
docker service create --name mysql -d --network myoverlay1 -p 3306:3306 test/mysql:5.5
docker-machine
Docker machine is to create a virtual machine with minimum Linux packages installed with docker running.
docker-machine ls
docker-machine start myvm1
docker-machine start myvm2
docker-machine ssh myvm1
docker swarm init --advertise-addr eth1
docker swarm join --token ...
docker-compose push
To access docker swarm master in docker machine from other host
docker-machine env myvml
eval $(docker-machine env myvm1)
docker stack deploy -c docker-compose.yml nodeapp
docker stack ls
docker stack services nodeapp
docker-machine ls
After the services started, all nodes, including master and worker nodes, will provide the services by routing to the correct host.
deploy:
replicas: 6
update_config:
parallelism: 2
delay: 10s
This indicates total of 6 replicas, and deploy 2 in parallel with 10 seconds delay.
deploy:
placement:
constraints: [node.role == manager]
This indicates that only manager node will be deployed.
docker service scale nodeapp_web=4
docker stack deploy -c docker-compose.monitoring.yml nodemon
docker stack ls
docker stack services nodemon
The service nodemon_visualizer
running on port 8080
docker node update myvm1 --label-add db=mongo
docker node inspect myvm1 -f {{.Spec.Labels}}
deploy:
placement:
constraints: [node.labels.db == mongo]
docker stack deploy -c docker-compose.yml nodeapp
docker node update --availability drain myvm2
docker node update --availability active myvm2
docker node update --availability=active myvm2
docker service update --force nodeapp_web
Update image:
option in docker-compose.yml
file
Then build again
docker-compose build
docker-compose push
docker stack deploy -c docker-compose.yml nodeapp
docker stack ps nodeapp
Then the containers will redeploy 2 at each time.
AWS supports Docker Swarm.
Introduction to Docker Swarm | Tutorial for Beginners | Examples | Typical Tasks (Video)
Docker Swarm Tutorial | Code Along | Zero to Hero under 1 Hour