Closed
Labels
Description
Description
the restart command ignores the depends_on constraint
Is this normal?
Steps To Reproduce
No response
Compose Version
Docker Compose version v2.32.4
Docker Environment
Client:
Version: 27.4.1
API version: 1.47
Go version: go1.22.10
Git commit: b9d17ea
Built: Tue Dec 17 15:44:45 2024
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 27.4.1
API version: 1.47 (minimum version 1.24)
Go version: go1.22.10
Git commit: c710b88
Built: Tue Dec 17 15:46:06 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.7.24
GitCommit: 88bf19b2105c8b17560993bee28a01ddc2f97182
runc:
Version: 1.2.3
GitCommit: v1.2.3-0-g0d37cfd
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Anything else?
No response
Activity
idsulik commentedon Jan 17, 2025
Please, fill the Steps To Reproduce section
ndeloof commentedon Jan 17, 2025
depends_onis only applied as container is created, until you explicitly declare a dependent service to require being restarted after it's dependency was updated/restarted, see https://docs.docker.com/reference/compose-file/services/#long-syntax-1yangjinheng commentedon Jan 17, 2025
I read this document, but it doesn't solve my problem. restart = true is not what I want.
I need the dependent service to be restarted after my service
Ensure data is saved correctly
yangjinheng commentedon Jan 17, 2025
all containers restart at the same time, and operations with dependencies will fail
ndeloof commentedon Jan 17, 2025
This is exactly what
restartis aboutPlease provide an illustration example. Reporting issue with a single sentence and none of the requested information won't bring you the best assistance we can offer
yangjinheng commentedon Jan 17, 2025
I want prod-quickadmin-1 to restart first, and then prod-mysql-1 to restart
yangjinheng commentedon Jan 17, 2025
The quickadmin service will capture the 15 signal and save some data to mysql
ndeloof commentedon Jan 17, 2025
IIUC you want
quickadminservice to be restart as you restartmysqlservice.Then
restartis what you needyangjinheng commentedon Jan 23, 2025
thanks for reply
i want to support depends_on in
docker compose restartdo not specify a service name
ndeloof commentedon Jan 23, 2025
restartdo supportdepends_on.Please provide a minimal example with the actual behavior and what you expect to be the desired behavior
yangjinheng commentedon Jan 23, 2025
thank you for your patience
look at this code, it is my application
after receiving the signal, it writes some data to the database
main.go
docker-compose.yaml
let's run it
then run
docker-compose down # because of depends_on the data is preservedrun as a comparison
docker-compose restart # data saving failedPrawinPracash commentedon Mar 19, 2025
Even I am facing the same issue. While 'systemctl restart docker' its restarting all the containers simultaneously but not considering depends_on and not spinning up the containers in a proper order. Is this issue fixed ? Please let me know.
yangjinheng commentedon Mar 19, 2025
problem not fixed.
I don't know why it was shut down.
ndeloof commentedon Mar 19, 2025
@PrawinPracash
systemctl restart dockeris unrelated to docker compose. This restarts docker daemon, so all container will be restarted at once.depends_onis a compose-only feature, that only applies todocker compose ..commands, engine isn't aware of such dependencies.