Docker mini project

What you will learn here about Docker

  • Docker mini project

Docker mini project

1)Initialize Docker Swarm

docker swarm init

2)Create a docker service with the following details

image: tomcat
name: http
Replicas: 2
port: 80
update-delay: 10s

docker service create --name http --replicas 2 -p 80 --update-delay 10s tomcat

3)Update the above service with a newer image tomcat

docker service update --image tomcat http

4)Scale the above service to 4 replicas

docker service update --replicas=4 http

5)Create a docker overlay network with name app-network

docker network create -d overlay app-network

6)Update http service and add it to app-network network

docker service update --network-add name=app-network http

7)Create a secret with name redis_password and content [email protected]

printf "[email protected]" | docker secret create redis_password -

8)Create another Docker service with following details

image: redis:alpine
name: redis
secret: redis_password
mode: global

docker service create --name redis --secret redis_password --mode global redis:alpine 

9)Update the Leader node and add a label color=red

Please Replace <HOSTNAME> With your hostname which is shown below

docker node ls

docker node update --label-add color=red <HOSTANME>

docker node update --label-add color=red

10)Create a docker service with tomcat image with name tomcat-red-only. Add a constraint that the service will be deployed on node with label color=red

docker service create --name tomcat-red-only --constraint node.labels.color==red tomcat

You may also like...