A script waiting for docker stack deploy command to complete.
Unfortunately, docker stack deploy always run in detached mode.
It means it exits immediately and doesn't wait for services to actually update.
This repo provides script that does the following:
- waits for all services in stack are updated (or errored)
- displays update progress per instance of each service
- returns exit code
0in case of success and1in case of errors
After calling docker stack deploy $STACK_NAME call the following:
docker run --rm vitalets/docker-stack-wait-deploy | bash /dev/stdin $STACK_NAMEExample output (progress):
STATUS (nodejs_service): updating
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
h1isbgdgmwv1 nodejs_service.1 nodejs_service_prod:1.5 swarm-manager Running Preparing 2 seconds ago
8zu8v3waxyjx \_ nodejs_service.1 nodejs_service_prod:1.4 swarm-manager Running Running 6 minutes ago
b45471xoq9d4 nodejs_service.2 nodejs_service_prod:1.4 swarm-manager Running Running 6 minutes ago
xyagddf48560 nodejs_service.3 nodejs_service_prod:1.5 swarm-manager Running Running 3 seconds ago
Example output (complete):
STATUS (nodejs_service): completed
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
h1isbgdgmwv1 nodejs_service.1 nodejs_service_prod:1.5 swarm-manager Running Running 18 seconds ago
rqpume7gxgnc nodejs_service.2 nodejs_service_prod:1.5 swarm-manager Running Running 5 seconds ago
xyagddf48560 nodejs_service.3 nodejs_service_prod:1.5 swarm-manager Running Running 31 seconds ago
Deployment successful.
docker build -t vitalets/docker-stack-wait-deploy .docker push vitalets/docker-stack-wait-deployMIT @ Vitaliy Potapov