Description
When setting stop_grace_period, for example 30s, this value is used when creating the container and saved as StopTimeout.
This value is used correctly by docker compose when stopping / recreating services, but not when restarting services! then a default of 10 seconds is used.
This is undesirable as some services require a longer grace period than others (e.g. a postgresql container needs more time to shutdown than a nginx container)
It is also undesirable having to always specify a custom timeout when restarting services as this can be forgotten by users and the required timeout can change over time when services are updated.
Steps To Reproduce
Reproduce using the following docker-compose.yml file:
services:
example:
image: busybox
command: 'sleep infinity'
stop_grace_period: 30s
Result of commands:
docker compose restart -> kill after 10 sec -> NOT OK
docker compose restart --timeout 2 -> kill after 2 sec -> OK
docker compose restart SERVICE -> kill after 10 sec -> NOT OK
docker compose restart SERVICE --timeout 2 -> kill after 2 sec -> OK
docker compose up --force-recreate -> kill after 30 sec -> OK
docker compose up --force-recreate --timeout 2 -> kill after 30 sec -> NOT OK
docker compose down -> kill after 30 sec -> OK
docker compose down --timeout 2 -> kill after 2 sec -> OK
docker compose stop SERVICE -> kill after 30 sec -> OK
docker compose stop --timeout 2 SERVICE -> kill after 2 sec -> OK
docker restart CONTAINER -> kill after 30 sec -> OK
docker restart --time 2 CONTAINER -> kill after 2 sec -> OK
docker stop CONTAINER -> kill after 30 sec -> OK
docker stop --time 2 CONTAINER -> kill after 2 sec -> OK
Compose Version
Docker Compose version v2.18.1
Docker Environment
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.10.2
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.18.1
Path: /usr/libexec/docker/cli-plugins/docker-compose
scan: Docker Scan (Docker Inc.)
Version: v0.23.0
Path: /usr/libexec/docker/cli-plugins/docker-scan
Server:
Containers: 10
Running: 9
Paused: 0
Stopped: 1
Images: 8
Server Version: 23.0.1
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: journald
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 2456e983eb9e37e47538f59ea18f2043c9a73640
runc version: v1.1.4-0-g5fd4c4d
init version: de40ad0
Security Options:
seccomp
Profile: builtin
Kernel Version: 4.18.0-425.13.1.el8_7.x86_64
Operating System: Rocky Linux 8.7 (Green Obsidian)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 7.581GiB
Name: example
ID: f99c6d57-2356-4977-aa04-b70bc1b8c3d0
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Anything else?
No response
Description
When setting
stop_grace_period, for example30s, this value is used when creating the container and saved asStopTimeout.This value is used correctly by
docker composewhen stopping / recreating services, but not when restarting services! then a default of 10 seconds is used.This is undesirable as some services require a longer grace period than others (e.g. a postgresql container needs more time to shutdown than a nginx container)
It is also undesirable having to always specify a custom timeout when restarting services as this can be forgotten by users and the required timeout can change over time when services are updated.
Steps To Reproduce
Reproduce using the following docker-compose.yml file:
Result of commands:
docker compose restart-> kill after 10 sec -> NOT OKdocker compose restart --timeout 2-> kill after 2 sec -> OKdocker compose restart SERVICE-> kill after 10 sec -> NOT OKdocker compose restart SERVICE--timeout 2 -> kill after 2 sec -> OKdocker compose up --force-recreate-> kill after 30 sec -> OKdocker compose up --force-recreate --timeout 2-> kill after 30 sec -> NOT OKdocker compose down-> kill after 30 sec -> OKdocker compose down --timeout 2-> kill after 2 sec -> OKdocker compose stop SERVICE-> kill after 30 sec -> OKdocker compose stop --timeout 2 SERVICE-> kill after 2 sec -> OKdocker restart CONTAINER-> kill after 30 sec -> OKdocker restart --time 2 CONTAINER-> kill after 2 sec -> OKdocker stop CONTAINER-> kill after 30 sec -> OKdocker stop --time 2 CONTAINER-> kill after 2 sec -> OKCompose Version
Docker Environment
Anything else?
No response