docker / for-win

Bug reports for Docker Desktop for Windows
https://www.docker.com/products/docker#/windows
1.86k stars 289 forks source link

Auto start doesn't respect compose depends_on #13968

Open goofballtech opened 7 months ago

goofballtech commented 7 months ago

Description

I have a docker compose set up as below. The mongo instance runs and is healthy before the maint container spins up when running from the compose but when docker desktop opens they both run in parallel so the mongo connection isn't yet present. When you restart then from the UI it give the same. If you stop the containers with the stop button then play them with the compose play then they will spin up properly with a 15 to 20 second delta in timing.

version: '3.5'
services:
  mongo:
    image: mongo:4.1.13
    container_name: mongo
    restart: unless-stopped
    networks:
      - datanet
    ports:
      - '27017:27017'
    volumes:
      - ./mongo/database:/data/db
      - ./mongo/init:/docker-entrypoint-initdb.d/
    environment:
      MONGO_INITDB_DATABASE: admin
      TZ: Etc/GMT0
    healthcheck:
      test: ["CMD", "if mongo --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)'; then exit 0; fi; exit 1;"]
      interval: 10s
      timeout: 10s
      retries: 3
      start_period: 20s
  maint:
    image: TheURL.com/ofMyImage
    container_name: maint
    restart: unless-stopped
    networks:
      - datanet
    ports:
      - '80:3000'
    volumes:
      - ./maint/supportDocs:/app/supportDocs
      - ./maint/logs:/app/logs
    environment:
      TZ: Etc/GMT0
    links:
      - mongo
    depends_on:
      mongo:
        condition: service_healthy
networks:
  datanet:

As starts and/or pressing restart within UI image

Stop and start with the stop/play button in UI or docker-compose up/docker-compose start at command line. image

Reproduce

docker-compose up reboot pc Containers do not come up in proper order

Expected behavior

the containers should adhere to the restraints specified in the compose file when docker desktop startup rather than ignoring them and spinning up both containers in parallel.

docker version

Client:
 Cloud integration: v1.0.35+desktop.11
 Version:           25.0.3
 API version:       1.44
 Go version:        go1.21.6
 Git commit:        4debf41
 Built:             Tue Feb  6 21:13:02 2024
 OS/Arch:           windows/amd64
 Context:           default

Server: Docker Desktop 4.28.0 (139021)
 Engine:
  Version:          25.0.3
  API version:      1.44 (minimum version 1.24)
  Go version:       go1.21.6
  Git commit:       f417435
  Built:            Tue Feb  6 21:14:25 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.28
  GitCommit:        ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client:
 Version:    25.0.3
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.12.1-desktop.4
    Path:     C:\Program Files\Docker\cli-plugins\docker-buildx.exe
  compose: Docker Compose (Docker Inc.)
    Version:  v2.24.6-desktop.1
    Path:     C:\Program Files\Docker\cli-plugins\docker-compose.exe
  debug: Get a shell into any image or container. (Docker Inc.)
    Version:  0.0.24
    Path:     C:\Program Files\Docker\cli-plugins\docker-debug.exe
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-dev.exe
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.22
    Path:     C:\Program Files\Docker\cli-plugins\docker-extension.exe
  feedback: Provide feedback, right in your terminal! (Docker Inc.)
    Version:  v1.0.4
    Path:     C:\Program Files\Docker\cli-plugins\docker-feedback.exe
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v1.0.1
    Path:     C:\Program Files\Docker\cli-plugins\docker-init.exe
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-sbom.exe
  scout: Docker Scout (Docker Inc.)
    Version:  v1.5.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-scout.exe

Server:
 Containers: 2
  Running: 2
  Paused: 0
  Stopped: 0
 Images: 2
 Server Version: 25.0.3
 Storage Driver: overlay2
  Backing Filesystem: extfs
  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 splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  seccomp
   Profile: unconfined
 Kernel Version: 5.15.133.1-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 3.759GiB
 Name: docker-desktop
 ID: 429952f3-69f8-4a06-a80c-de0ddb3cfd70
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
WARNING: daemon is not using the default seccomp profile

Diagnostics ID

5717D1B3-8ABD-4E76-B937-67774A9DB9EF/20240312005310

Additional Info

No response

ATFieldBeast commented 5 months ago

i have the same situation, i use docker compose in ubuntu, but when i reboot my machine, the docker doesn't respect compose depends_on condition order; when i use 'docker compose up -d', the depends_on condition order works well. (and i find that when machine reboot, the container actually doesn`t refresh, when use 'docker compose down' and 'docker compose up -d', the container just refresh) Snipaste_2024-04-29_13-33-51