compose icon indicating copy to clipboard operation
compose copied to clipboard

[BUG] Docker hangs when trying to shutdown containers with this setup

Open errol59 opened this issue 11 months ago • 6 comments

Description

Since v.2.24 (possibly way before) some behaviour has changed in the way volume mounting and binding works.

What I try to achieve with this setup is that code that I normally share between the frontend and backend is immediately available in their respective container's node module folder when I make a change to the shared code. While the overall setup works as expected, trying to stop and remove containers inconsistently throws the following error:

Cannot remove Docker Compose application. Reason: compose [down --remove-orphans] exit status 1. Container frontend Stopping Removed Container frontend Stopped Container frontend Removing Container frontend Removed Container backend Stopping Container backend Error while Stopping Error response from daemon: cannot stop container: e5c94ada453168af2b1f51ddce2ff301b5f9be37d19dd07e767df707a718b049: tried to kill container, but did not receive an exit event

When this error occurs, Docker is just stuck. I can't remove or stop any containers, execute any docker commands and my CPU usage skyrockets. The only way of stopping and removing the containers is by executing the following command taskkill /F /IM wslservice.exe, restarting Docker (desktop) and praying that I can stop and remove the containers the next attempt.

Steps To Reproduce

Structure of my Docker compose file:

  version: "3.8"

services:
  frontend:
    image: node-frontend
    volumes:
      - type: bind
        source: ./app/frontend
        target: /usr/src/app
      - type: volume
        source: frontend-node_modules
        target: /usr/src/app/node_modules
      - type: bind
        source: ./app/shared_library
        target: /usr/src/app/node_modules/shared_library
  
  backend:
    image: node-backend
    volumes:
      - type: bind
        source: ./app/backend
        target: /usr/src/app
      - type: volume
        source: backend-node_modules
        target: /usr/src/app/node_modules
      - type: bind
        source: ./app/shared_library
        target: /usr/src/app/node_modules/shared_library

  shared-library:
    image: node-shared_library
    volumes:
      - type: bind
        source: ./app/shared_library
        target: /usr/src/app
      - type: volume
        source: shared-node_modules
        target: /usr/src/app/node_modules

volumes:
  frontend-node_modules:
  backend-node_modules:
  shared-node_modules:

Compose Version

❯ docker compose version
Docker Compose version v2.24.5-desktop.1
❯ docker-compose version
Docker Compose version v2.24.5-desktop.1

Docker Environment

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.5-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.21
    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.0
    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.4.1
    Path:     C:\Program Files\Docker\cli-plugins\docker-scout.exe

Server:
 Containers: 7
  Running: 7
  Paused: 0
  Stopped: 0
 Images: 115
 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: 24
 Total Memory: 15.56GiB
 Name: docker-desktop
 ID: 67bab2f0-16b1-4e7e-b02f-f29f3f2b7717
 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

Anything else?

No response

errol59 avatar Mar 06 '24 13:03 errol59

Can you collect a diag and share the ID here? https://docs.docker.com/desktop/troubleshoot/overview/#diagnose-from-the-terminal

Are you working inside WSL2?

milas avatar Mar 06 '24 21:03 milas

Can you collect a diag and share the ID here?

Here you go: 9C268793-1557-4644-93ED-96DA0B4A7DB0/20240307093912

Are you working inside WSL2?

Yes, I'm using Docker with the WSL2 integration on Windows.

errol59 avatar Mar 07 '24 09:03 errol59

@milas hello, I ran into a similar problem in docker desktop on windows in the hyper-v configuration. after some time, the containers stop responding to network ports, and I can't do anything with running containers either. workaround only restart docker engine + stop hyper-vm. however, after a while it repeats

Diagnostics ID: 84FDC075-495C-46D8-9422-7D2F5EA225E7/20240315090421

# docker compose version
Docker Compose version v2.24.6-desktop.1
# docker compose down
[+] Running 2/2
 ✘ Container nppct-mp-db-1         Error while Stopping                                                           24.0s
 ✘ Container nppct-mp-wordpress-1  Error while Stopping                                                           39.6s
Error response from daemon: cannot stop container: 85beb89c3f00a91297d7678cded50c20ba9130610078b07ba78ac576f8d85521: tried to kill container, but did not receive an exit event

mark99i avatar Mar 15 '24 09:03 mark99i

@mark99i, are you able to share the stack you are using for your project? Maybe our projects share commonalities that trigger this hang up.

errol59 avatar Mar 18 '24 10:03 errol59

@errol59

version: '3.9'


name: nppct-mp

services:
  wordpress:
    image: wordpress:beta-php8.3-apache
    restart: unless-stopped
    ports:
      - 0.0.0.0:8085:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: *
      WORDPRESS_DB_PASSWORD: *
      WORDPRESS_DB_NAME: *
      WORDPRESS_DEBUG: 1
      WORDPRESS_CONFIG_EXTRA: >
        define("WP_REDIS_HOST", "redis");
        define("WP_REDIS_DATABASE", 0);
        define("WP_REDIS_PASSWORD", "*");
        define("SAVEQUERIES", true);

    volumes:
      - ./wordpress:/var/www/html

  db:
    image: mariadb:latest
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: *
      MYSQL_USER: *
      MYSQL_PASSWORD: *
      MYSQL_RANDOM_ROOT_PASSWORD: '*'
      MARIADB_AUTO_UPGRADE: 1
    ports:
      - 8084:3306
    volumes:
      - ./db:/var/lib/mysql

  redis:
    image: redis:latest
    command: redis-server --loglevel warning --requirepass *
    restart: unless-stopped

mark99i avatar Mar 18 '24 10:03 mark99i

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Aug 18 '24 00:08 github-actions[bot]