Part 4 – Docker Swarm

 Help 
docker-compose help 

# Docker compose works on directory
mkdir test

# Version 
docker-compose version

# Check docker-compose syntax
docker-compose config

# Start Docker Compose
docker-compose up -d
– d detached mode

# Specifiy override files in case we need to specify ports  
docker-compose -f docker-compose.yml -f docker-compose-dev.mac.yml up -d 

#Bring Down application started via Docker Compose and remove all containers it created 
get in directory and run 
docker-compose down

#Deploy Compose Stack:
docker stack deploy –compose-file docker-compose.yml <name>

#Show stack
docker stack ls
docker stack ps stack02-wordpress –filter desired-state=running

#Remove Stack
docker stack rm mydemo

# To display/locate the running service in a stack
docker stack ps <servicename>
docker stack ps east-webservers 

# To display/locate the running service in a swarm with desired config 
docker stack ps east-webservers –filter DESIRED-STATE=running
docker stack ps east-webservers –filter DESIRED-STATE=running –filter NODE=swarm1011

#Scaling Up Operation
docker service scale <service name>
docker service scale webserver=5
or
docker service update –replicas 2 webserver

#Scaling Down Operation
docker service scale webserver=1

#Verify Service Details:
docker service ls
docker service ps webserver

#Remove Service After Practical:
docker service rm webserver

docker-compose up -d       Start your services defined in docker-compose.yml
docker-compose down        Stop services
docker-compose restart  Restart services
docker network ls               Show docker networks
docker volume ls                  Show docker volumes
docker inspect <containerId>  Inspect container with containerId *

# Starts all stopped containers in the work directory
docker-compose start
# Stops all currently running containers in the work directory
docker-compose stop
# Validates and shows the configuration
docker-compose config
# Lists all running containers in the work directory
docker-compose ps
# Stops and removes all containers in the work directory
docker-compose down

(Visited 29 times, 1 visits today)

By C A Thomas

Chinchu A. Thomas is an Infrastructure Analyst specializing in Microsoft Azure, the Microsoft 365 suite, AWS, and Windows infrastructure management products.

Leave a Reply