JavaScript required
We’re sorry, but Coda doesn’t work properly without JavaScript enabled.
Skip to content
Gallery
DevOps
Kubernetes (K8s)
Docker
HELM
Ansible
Linux Commands
More
Share
Explore
Docker Swarm (Orchestration Service by docker)
Docker Stack
version: "3"
services:
# Service Name Defined as web
web:
# Pull the Image from Repository.
# replace username/repo:tag with your name and image details
image: anshuldevops/frindly_hello:latest
# Command used to deploy the Service
deploy:
# Run 5 instances of that image as a service called web
replicas: 5
resources:
# Limiting each one to use, at most, 10% of a single core of CPU time and 50MB of RAM.
limits:
cpus: "0.1"
memory: 50M
# Immediately restart containers if one fails.
restart_policy:
condition: on-failure
# Map port 4000 on the host to web’s port 80.
ports:
- "4000:80"
# Define default network
networks:
- webnet
visualizer:
image: dockersamples/visualizer:stable
ports:
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
deploy:
placement:
constraints: [node.role == manager]
networks:
- webnet
redis:
image: redis
ports:
- "6379:6379"
volumes:
- "./data:/data"
deploy:
placement:
constraints: [node.role == manager]
command: redis-server --appendonly yes #for persistent data volume
networks:
- webnet
networks:
webnet:
Deploying the same multi node application that we deployed before but using docker stack and yaml file
version: "3"
services:
redis:
image: redis:alpine
networks:
- frontend
deploy:
replicas: 1
update_config:
parallelism: 2
delay: 10s
restart_policy:
condition: on-failure
db:
image: postgres:9.4
volumes:
- db-data:/var/lib/postgresql/data
networks:
- backend
deploy:
placement:
constraints: [node.role == manager]
vote:
image: dockersamples/examplevotingapp_vote:before
ports:
- 5000:80
networks:
- frontend
depends_on:
- redis
deploy:
replicas: 2
update_config:
parallelism: 2
restart_policy:
condition: on-failure
result:
image: dockersamples/examplevotingapp_result:before
ports:
- 5001:80
networks:
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
Ctrl
P
) instead.