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] docker compose up -d --wait option with restart polilcy 'no' #11638

Closed
skul87 opened this issue Mar 20, 2024 · 3 comments
Closed

[BUG] docker compose up -d --wait option with restart polilcy 'no' #11638

skul87 opened this issue Mar 20, 2024 · 3 comments

Comments

@skul87
Copy link

skul87 commented Mar 20, 2024

Description

Hello, I have run docker compose up -d --wait
In docker-compose.yml there is a init service with restart police - 'no'

docker compose up -d --wait ends with return code 1 and my ci will fail.

may be if service return 0 code, then assume that everything is fine ?

[runner@partners-dev partners]$ cat docker/docker-compose.yml
services:
  db:
    build:
      args:
        MYSQL_TAG: ${MYSQL_TAG}
      context: ../
      dockerfile: docker/mysql/Dockerfile
    restart: always
    environment:
      TZ: ${TZ}
    healthcheck:
      test:
        [
          "CMD-SHELL",
          "sh -c 'mysqladmin ping -h 127.0.0.1 -u ${DB_USERNAME} --password=${DB_PASSWORD}'"
        ]
      interval: 5s
      timeout: 4s
      retries: 40
    volumes:
      - db-storage:/var/lib/mysql
      - db-logs:/var/log/mysql
  app:
    build:
      args:
        uid: ${UID}
        gid: ${GID}
        php_tag: ${PHP_TAG}
      context: ../
      dockerfile: docker/php-fpm/dev/Dockerfile
    entrypoint: [ "sleep" ]
    command: [ "999" ]
    restart: always
    environment:
      TZ: ${TZ}
    volumes:
      - ../app:/app
  init:
    build:
      args:
        uid: ${UID}
        gid: ${GID}
        php_tag: ${PHP_CLI_TAG}
      context: ../
      dockerfile: docker/php-fpm/dev/Dockerfile
    entrypoint: [ "date" ]
    restart: "no"
    environment:
      TZ: ${TZ}
    volumes:
      - ../app:/app

volumes:
  db-storage:
  db-logs:


networks:
  default:
[runner@partners-dev partners]$ docker compose version
Docker Compose version v2.25.0
[runner@partners-dev partners]$ docker compose up -d --wait
[+] Running 2/6
 ⠹ Network example-compose98_default      Created                                                                                                                                                                                                                             139.3s
 ⠹ Volume "example-compose98_db-storage"  Created                                                                                                                                                                                                                             139.2s
 ⠹ Volume "example-compose98_db-logs"     Created                                                                                                                                                                                                                             139.2s
 ✔ Container example-compose98-app-1      Healthy                                                                                                                                                                                                                               1.2s
 ⠹ Container example-compose98-init-1     Waiting                                                                                                                                                                                                                             139.2s
 ✔ Container example-compose98-db-1       Healthy                                                                                                                                                                                                                             139.2s
container example-compose98-init-1 exited (0)
[runner@partners-dev partners]$ echo $?
1

Steps To Reproduce

  1. create docker-compose.yml containing service with policy: 'no'
  2. docker compose up -d --wait
  3. echo $?

Compose Version

Docker Compose version v2.25.0

Docker Environment

Client: Docker Engine - Community
 Version:    24.0.6
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.2
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.25.0
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 45
  Running: 37
  Paused: 0
  Stopped: 8
 Images: 344
 Server Version: 24.0.6
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 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: 8165feabfdfe38c65b599c4993d227328c231fca
 runc version: v1.1.8-0-g82f18fe
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
 Kernel Version: 3.10.0-1160.95.1.el7.x86_64
 Operating System: CentOS Linux 7 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 5.669GiB
 Name: partners-dev.ru-central1.internal
 ID: 10863e99-96cf-4bb5-a5e9-d1c2684c8541
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Default Address Pools:
   Base: 172.17.0.0/12, Size: 27

Anything else?

No response

@ndeloof
Copy link
Contributor

ndeloof commented Mar 20, 2024

--wait let compose wait for services to become healthy, it's unrelated to service termination. Here compose fails as service container exited, while a service is supposed to be a long-running process

@pkoutsovasilis
Copy link

@ndeloof I think that this PR helps with similar scenarios as the one posted in this issue. To be clear, I get that --wait is targeting long-running processes and this is a design choice which I agree with. But imo having an extra flag to include support for services exiting with code 0 during wait isn't that distorting to the former design. 🙂

@ndeloof
Copy link
Contributor

ndeloof commented Mar 27, 2024

closing as a duplicate for #10596

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

4 participants