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 down fails with "No exec command specified" in pre_stop hook #12554

Closed
jira-zz opened this issue Feb 13, 2025 · 4 comments · May be fixed by compose-spec/compose-go#739
Closed
Assignees

Comments

@jira-zz
Copy link

jira-zz commented Feb 13, 2025

Description

Using docker compose, I want to clean files in pre_stop hook.
When I stop compose with docker compose down, I get an error Error response from daemon: No exec command specified and compose is not stopped.
I can reproduce this with the following minimal docker-compose.yaml.

services:
  teardown-test:
    image: bash
    command: "tail -f /dev/null"
    pre_stop:
      - command: ["echo", "stopping"]
      - user: root

Steps To Reproduce

Using the provided docker compose config run:

  • docker compose up
  • docker compose down

Compose should stop gracefully, but instead an error Error response from daemon: No exec command specified is returned and compose continues to run

Compose Version

Docker Compose version v2.32.4-desktop.1

Docker Environment

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  ai: Ask Gordon - Docker Agent (Docker Inc., v0.7.3)
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.20.1-desktop.2)
  compose: Docker Compose (Docker Inc., v2.32.4-desktop.1)
  debug: Get a shell into any image or container (Docker Inc., 0.0.38)
  desktop: Docker Desktop commands (Beta) (Docker Inc., v0.1.4)
  dev: Docker Dev Environments (Docker Inc., v0.1.2)
  extension: Manages Docker extensions (Docker Inc., v0.2.27)
  feedback: Provide feedback, right in your terminal! (Docker Inc., v1.0.5)
  init: Creates Docker-related starter files for your project (Docker Inc., v1.4.0)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scout: Docker Scout (Docker Inc., v1.16.1)
WARNING: Plugin "/usr/local/lib/docker/cli-plugins/docker-scan" is not valid: failed to fetch metadata: fork/exec /usr/local/lib/docker/cli-plugins/docker-scan: no such file or directory

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 79
 Server Version: 27.5.1
 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 nvidia runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: bcc810d6b9066471b0b6fa75f557a15a1cbf31bb
 runc version: v1.1.12-0-g51d5e946
 init version: de40ad0
 Security Options:
  seccomp
   Profile: unconfined
 Kernel Version: 5.15.167.4-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 15.51GiB
 Name: docker-desktop
 ID: 2f6dd723-a215-4c8b-964d-8efe56836f80
 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
 Registry: https://index.docker.io/v1/
 Labels:
  com.docker.desktop.address=unix:///var/run/docker-cli.sock
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

No response

@ndeloof
Copy link
Contributor

ndeloof commented Feb 13, 2025

This is a syntax issue: here you declare 2 entries in pre_stop. Need to use:

services:
  teardown-test:
    image: bash
    command: "tail -f /dev/null"
    pre_stop:
      - command: ["echo", "stopping"]
        user: root 

This should be validated as we load the model, le me prepare a PR for this purpose

@jira-zz
Copy link
Author

jira-zz commented Feb 14, 2025

This is a syntax issue: here you declare 2 entries in pre_stop. Need to use:

services:
teardown-test:
image: bash
command: "tail -f /dev/null"
pre_stop:
- command: ["echo", "stopping"]
user: root

This should be validated as we load the model, le me prepare a PR for this purpose

You are right, with this change it works. Quite embarrassing I overlooked this.

@glours
Copy link
Contributor

glours commented Feb 18, 2025

@jira-zz is it ok for you if we close the issue?

@jira-zz
Copy link
Author

jira-zz commented Feb 19, 2025

@jira-zz is it ok for you if we close the issue?

yes, go ahead

@glours glours closed this as completed Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants