docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
34.02k stars 5.23k forks source link

[BUG] `docker compose` V2 CLI hanging and becoming unresponsive when there's a failure to build image #10752

Closed SishaarRao closed 1 year ago

SishaarRao commented 1 year ago

Description

I am using docker compose to build a network of images that communicate and work with eachother. I've noticed that, if for some reason there's a failure to build an image out of one of the services, and docker-compose displays an error message, the entire CLI just seems to hang and becomes uncancellable. The Building timer continues to roll, but the CLI seems to completely ignore SIGINT's.

The only way for me to resolve this issue is by opening up my MacOS Activity Monitor and force killing the docker-compose task

[+] Building 121.6s (30/30)
 => [answering-machine-detection internal] load .dockerignore                                                                                                                            0.0s
 => => transferring context: 121B                                                                                                                                                        0.0s
 => [answering-machine-detection internal] load build definition from Dockerfile                                                                                                         0.0s
 => => transferring dockerfile: 1.07kB                                                                                                                                                   0.0s
 => [answering-machine-detection internal] load metadata for docker.io/library/python:3.11.2                                                                                             2.3s
 => [answering-machine-detection auth] library/python:pull token for registry-1.docker.io                                                                                                0.0s
 => [answering-machine-detection  1/12] FROM docker.io/library/python:3.11.2@sha256:5329e75033c4446dc92d702cf8ebbeb63e549d9b83076a776f6753e10817fc3c                                     0.0s
 => => resolve docker.io/library/python:3.11.2@sha256:5329e75033c4446dc92d702cf8ebbeb63e549d9b83076a776f6753e10817fc3c                                                                   0.0s
 => [answering-machine-detection internal] load build context                                                                                                                            0.0s
 => => transferring context: 46.66kB                                                                                                                                                     0.0s
 => CACHED [answering-machine-detection  2/12] WORKDIR /app                                                                                                                              0.0s
 => CACHED [answering-machine-detection  3/12] COPY requirements.txt .                                                                                                                   0.0s
 => CACHED [answering-machine-detection  4/12] RUN apt-get update && apt-get install -y wget g++                                                                                         0.0s
 => CACHED [answering-machine-detection  5/12] RUN wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O cloud_sql_proxy                                                    0.0s
 => CACHED [answering-machine-detection  6/12] RUN chmod +x cloud_sql_proxy                                                                                                              0.0s
 => CACHED [answering-machine-detection  7/12] RUN pip install --upgrade pip setuptools                                                                                                  0.0s
 => CACHED [answering-machine-detection  8/12] RUN pip install -r requirements.txt                                                                                                       0.0s
 => [answering-machine-detection  9/12] COPY . .                                                                                                                                         0.0s  => [answering-machine-detection 10/12] COPY entrypoint.sh /app/                                                                                                                         0.0s
 => [answering-machine-detection 11/12] RUN chmod +x /app/entrypoint.sh                                                                                                                  0.1s
 => [answering-machine-detection 12/12] RUN mkdir -p ./bin/metrics/                                                                                                                      0.3s
 => [answering-machine-detection] exporting to image                                                                                                                                     0.1s
 => => exporting layers                                                                                                                                                                  0.1s
 => => exporting manifest sha256:dc96bce9974e00de224aef75fc09e7f4f46ea93da0a5350448392cd601961d7f                                                                                        0.0s
 => => exporting config sha256:82667932ced0f31dd8af33fe022a6e7ecbf3cbc5b1269fe3ecbfdbf4bc201907                                                                                          0.0s
 => => exporting attestation manifest sha256:2aafb93f4c54704f6255b7b15db7a518eb15d587a5f04ac6f4a765f439272797                                                                            0.0s
 => => exporting manifest list sha256:494ef969519b10caccc870934a6dad97edccfbfd6318dda520407242f769d6dc                                                                                   0.0s
 => => naming to docker.io/library/nooksin-answering-machine-detection:latest                                                                                                            0.0s
 => => unpacking to docker.io/library/nooksin-answering-machine-detection:latest                                                                                                         0.0s
 => [functions internal] load build definition from Dockerfile                                                                                                                           0.0s
 => => transferring dockerfile: 883B                                                                                                                                                     0.0s
 => [functions internal] load .dockerignore                                                                                                                                              0.0s
 => => transferring context: 92B                                                                                                                                                         0.0s
 => [functions internal] load metadata for docker.io/library/node:16.19.1-alpine                                                                                                         1.5s
 => [functions auth] library/node:pull token for registry-1.docker.io                                                                                                                    0.0s
 => [functions build 1/2] FROM docker.io/library/node:16.19.1-alpine@sha256:90f5adf9a338b2d88b2d35488e6e5ce9b1fb6be211b57c8c09218791ac4097d4                                             0.0s
 => => resolve docker.io/library/node:16.19.1-alpine@sha256:90f5adf9a338b2d88b2d35488e6e5ce9b1fb6be211b57c8c09218791ac4097d4                                                             0.0s
 => [functions internal] load build context                                                                                                                                              0.1s
 => => transferring context: 2.08MB                                                                                                                                                      0.1s
 => CACHED [functions build 2/2] RUN apk add --no-cache g++ make py3-pip                                                                                                                 0.0s
 => CACHED [functions development 1/5] WORKDIR /app                                                                                                                                      0.0s
 => [functions development 2/5] COPY ./frontend ./frontend                                                                                                                               0.3s
 => [functions development 3/5] COPY ./functions ./functions                                                                                                                             0.2s
 => [functions development 4/5] WORKDIR /app/functions                                                                                                                                   0.0s
 => ERROR [functions development 5/5] RUN npm install -g npm@latest &&     npm install &&     npm run build
^C^C^C^C^C

Steps To Reproduce

Run on MacOS 13.4.1 I have Virtualization Framework, VirtioFS, Rosetta, and containerd enabled

Here's my docker-compose.yml. functions here is a Node Alpine image that has some Typescript compilation code and NPM install. Let one of these fail, say a failure in tsc -> that leads to the entire docker compose CLI freezing up.

version: "3.8"

services:
  functions:
    container_name: functions
    build:
      dockerfile: functions/Dockerfile
      target: development
      context: .
      args:
        - ENVIRONMENT=development
    environment:
      - CLOUD_FUNCTIONS_BASE_URL=https://${NGROK_SUBDOMAIN:-default_subdomain}.ngrok.io
      - MOTIFS_DB_HOST=cloud-sql-proxy
    ports:
      - 5001:5001
    networks:
      - default
    volumes:
      - ./functions/src:/app/functions/src
    depends_on:
      - cloud-sql-proxy

  # Cloud SQL Proxy
  cloud-sql-proxy:
    container_name: cloud-sql-proxy
    image: gcr.io/cloudsql-docker/gce-proxy:1.16
    command: /cloud_sql_proxy -instances=<elided>
    volumes:
      - ~/.config/gcloud:/root/.config/gcloud
    networks:
      - default

  # NGROK Configurations
  functions-ngrok:
    container_name: functions-ngrok
    image: wernight/ngrok
    ports:
      - 4040:4040
    environment:
      - NGROK_PORT=functions:5001
      - NGROK_SUBDOMAIN=${NGROK_SUBDOMAIN:-default_subdomain}
      - NGROK_AUTH=<elided>
    depends_on:
      - functions
    networks:
      - default

Compose Version

Docker Compose version v2.18.1

Docker Environment

❯ docker info
Client:
 Version:    24.0.2
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.10.5
    Path:     /Users/sishaar/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.18.1
    Path:     /Users/sishaar/.docker/cli-plugins/docker-compose
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.0
    Path:     /Users/sishaar/.docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.19
    Path:     /Users/sishaar/.docker/cli-plugins/docker-extension
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v0.1.0-beta.4
    Path:     /Users/sishaar/.docker/cli-plugins/docker-init
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /Users/sishaar/.docker/cli-plugins/docker-sbom
  scan: Docker Scan (Docker Inc.)
    Version:  v0.26.0
    Path:     /Users/sishaar/.docker/cli-plugins/docker-scan
  scout: Command line tool for Docker Scout (Docker Inc.)
    Version:  v0.12.0
    Path:     /Users/sishaar/.docker/cli-plugins/docker-scout

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 5
 Server Version: 24.0.2-38-g8e70a1b23e
 Storage Driver: stargz
  driver-type: io.containerd.snapshotter.v1
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 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: 3dce8eb055cbb6872793272b4f20ed16117344f8
 runc version: v1.1.7-0-g860f061
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.15.49-linuxkit-pr
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 8
 Total Memory: 7.765GiB
 Name: docker-desktop
 ID: d8121003-641b-4ef9-8fb7-1b8113ed24f4
 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

Anything else?

No response

SishaarRao commented 1 year ago

Never mind, looks like it's caused by the following issue https://github.com/docker/compose/issues/10728

Removed all my depends_on clauses and that fixed the issue