Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Service restarts, even if dependency did not restart successfully #12098

Open
trivialkettle opened this issue Sep 2, 2024 · 3 comments

Comments

@trivialkettle
Copy link

Description

Hi,

I have the following compose.yaml:

name: test

services:
  job:
    image: busybox:latest
    command: echo Hello World
    depends_on:
      job2:
        condition: service_completed_successfully

  job2:
    image: busybox:latest
    command: /bin/sh -c 'invalidcommand' # trigger error code

If I run docker compose up job2 does not complete successfully and job is not started (all good). Though if I run docker compose restart job gets started, even if job2 does not complete successfully.

The same behavior can be observed, if restart: true is set and docker compose restart job2 is called.

Steps To Reproduce

  1. Use compose.yaml shown above
  2. run docker compose up, job should not get started
  3. run docker compose restart, now job gets started, even if job2 does not complete successfully

Compose Version

Docker Compose version 2.29.2

Docker Environment

Client:
 Version:    27.2.0
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  0.16.2
    Path:     /usr/lib/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  2.29.2
    Path:     /usr/lib/docker/cli-plugins/docker-compose
  scan: Docker Scan (Docker Inc.)
    Version:  v0.1.0-280-gc7fa31d4c4
    Path:     /usr/lib/docker/cli-plugins/docker-scan

Server:
 Containers: 38
  Running: 14
  Paused: 0
  Stopped: 24
 Images: 192
 Server Version: 27.1.2
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: true
  Native Overlay Diff: false
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 8fc6bcff51318944179630522a095cc9dbf9f353.m
 runc version: 
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.10.6-arch1-1
 Operating System: Arch Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 30.74GiB
 Name: Pulse15-01
 ID: 10d8688d-7351-44fd-8668-39ea0eae5fe5
 Docker Root Dir: /home/vg-docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

No response

@ndeloof
Copy link
Contributor

ndeloof commented Sep 3, 2024

restart command does not handle depends_on condition, which applies to container creation / initial start. restart just force container process to restart, but assigned resources (network, volumes, ...) are the same.
Can you please clarify the use-case you have for restart command ?

@trivialkettle
Copy link
Author

I have a data broker, an init container and some container that work on these data. I tried to use restart the init container to reconfigure the broker and at the same time restart all dependencies.

So I guess I need to use docker compose up and docker compose down

@ndeloof
Copy link
Contributor

ndeloof commented Sep 3, 2024

support for init container in Compose is indeed very minimal. Using up & down is probably the best workaround I can suggest.
I'll tag this issue as a feature request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants