Stop grace period doesn't work as expected
- [x] This is a bug report
- [ ] This is a feature request
- [x] I searched existing issues before opening this one
I am running Docker in swarm mode with several nodes in the cluster. According to the documentation written here: https://docs.docker.com/engine/reference/commandline/service_update/ and here: https://docs.docker.com/engine/reference/commandline/service_create/, --stop-grace-period command sets the time to wait before force killing a container.
Expected behavior
My expectation was that Docker would wait this period of time until it tries to stop a running container, during a rolling update.
Actual behavior
Docker sends the termination signal after several seconds the new container with the new version of the image starts.
Steps to reproduce the behavior
-
docker service create --replicas 1 --stop-grace-period 60s --update-delay 60s --update-monitor 5s --update-order start-first --name nginx nginx:1.15.8
-
Wait for the service to start up the container (aprox. 2 minutes)
-
docker service update --image nginx:1.15.9 nginx
-
docker ps -a

-
As you can see, the new container started and after a second, the old one was killed by Docker.
Output of docker version:
Client:
Version: 18.09.2
API version: 1.39
Go version: go1.10.6
Git commit: 6247962
Built: Sun Feb 10 04:13:47 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.2
API version: 1.39 (minimum version 1.12)
Go version: go1.10.6
Git commit: 6247962
Built: Sun Feb 10 03:42:13 2019
OS/Arch: linux/amd64
Experimental: false
Output of docker info:
Containers: 2
Running: 2
Paused: 0
Stopped: 0
Images: 1
Server Version: 18.09.2
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: active
NodeID: fe5jda8ejamupm30sqhh8s5zt
Is Manager: true
ClusterID: ebmcxcoh0nu3frc2efnnfav8s
Managers: 6
Nodes: 11
Default Address Pool: 10.0.0.0/8
SubnetSize: 24
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Number of Old Snapshots to Retain: 0
Heartbeat Tick: 1
Election Tick: 10
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Force Rotate: 0
Autolock Managers: false
Root Rotation In Progress: false
Node Address: N/A
Manager Addresses: N/A
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9754871865f7fe2f4e74d43e2fc7ccd237edcbce
runc version: 09c8266bf2fcf9519a651b04ae54c967b9ab86ec
init version: fec3683
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.15.0-45-generic
Operating System: Ubuntu 18.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 4GiB
Name: docker-swarm-01
ID: 5DYH:RGFF:OXVU:IGR7:LC44:ZUJ3:2ZRG:CSYV:H5FS:GYGX:DMVO:COFU
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine
WARNING: No swap limit support
Additional environment details (AWS, VirtualBox, physical, etc.)
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
Close this issue, it works as designed. Behaviour explained in the stackoverflow question from the issue author: https://stackoverflow.com/questions/55103543/docker-swarm-stop-grace-period-doesnt-work-as-expected