-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
Description
Contributing guidelines and issue reporting guide
- I've read the contributing guidelines and wholeheartedly agree. I've also read the issue reporting guide.
Well-formed report checklist
- I have found a bug that the documentation does not mention anything about my problem
- I have found a bug that there are no open or closed issues that are related to my problem
- I have provided version/information about my environment and done my best to provide a reproducer
Description of bug
Bug description
When a base image defines a CMD and the child image only sets ENTRYPOINT, the child image ends up with CMD: null. Per Dockerfile/OCI expectations, the base CMD should be inherited and used as default args to the new ENTRYPOINT.
I thought this was maybe intentional, but I've searched all over and it really seems like in this situation, it should inherit the CMD. If clearing the CMD when you provide ENTRYPOINT is intentional functionality, then maybe the docs need to be updated to point out this edge case.
Reproduction
Dockerfile.base:
FROM busybox:latest
CMD ["echo base cmd"]Dockerfile.child:
FROM repro-base:latest
# Intentionally override ENTRYPOINT only; CMD should be inherited
ENTRYPOINT ["/bin/sh","-c"]Build and inspect:
docker build -f Dockerfile.base -t repro-base .
docker build -f Dockerfile.child -t repro-child .
docker image inspect repro-base --format '{{json .Config.Entrypoint}} {{json .Config.Cmd}}'
docker image inspect repro-child --format '{{json .Config.Entrypoint}} {{json .Config.Cmd}}'Observed:
Base image: null ["echo base cmd"]
Child image: ["/bin/sh","-c"] null
Expected:
Child image should retain CMD from base:
["/bin/sh","-c"] ["echo base cmd"]
Version information
docker buildx version
github.com/docker/buildx v0.30.1-desktop.1
docker buildx inspect
Name: owlwood
Driver: docker
BuildKit version: v0.27.0
Platforms: linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/386
docker version
Client: 29.2.0 (darwin/arm64)
Server: 29.2.1 (linux/amd64)
docker info (server excerpt)
Server Version: 29.2.0
Storage Driver: overlay2
Cgroup Driver: systemd
Cgroup Version: 2
Kernel Version: 6.8.0-94-generic
Operating System: Ubuntu 24.04.3 LTS
Architecture: x86_64Reactions are currently unavailable