-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Description
BUG REPORT INFORMATION
Description
If I run a one-off container based on a service definition using the run subcommand and override the entrypoint, Compose 2.6.0 fails to clear the default command (default arguments to the default entrypoint) as well. As far as I can think of, every other Docker interface to override the entrypoint also clears CMD:
docker-compose runin v1- the
runsubcommand of Docker itself:
Note: Passing
--entrypointwill clear out any default command set on the image (i.e. anyCMDinstruction in the Dockerfile used to build it).
- Compose YAML files according to the Compose spec:
Compose implementations MUST clear out any default command on the Docker image - both
ENTRYPOINTandCMDinstruction in the Dockerfile - whenentrypointis configured by a Compose file.
- Older versions of the Compose YAML file format:
Note: Setting
entrypointboth overrides any default entrypoint set on the service’s image with theENTRYPOINTDockerfile instruction, and clears out any default command on the image - meaning that if there’s aCMDinstruction in the Dockerfile, it is ignored.
Steps to reproduce the issue:
- Define a service with both an entrypoint and a default command to pass to it, e.g.
services:
database:
image: mysql:8.0
command: ["--help"]- Run a docker compose run command that overrides the entrypoint with a different executable, e.g.
$ docker compose run --rm --entrypoint=ls databaseDescribe the results you received:
The new entrypoint, ls, responds as if it was passed the default arguments intended for the original entrypoint, namely the --help, flag, and prints a usage message.`
Describe the results you expected:
I expected the new entrypoint, ls, to be run without arguments and list the files in the container's working directory.
Additional information you deem important (e.g. issue happens only occasionally):
None.
Output of docker compose version:
Docker Compose version v2.6.0
Output of docker info:
Snippet:
Client:
Context: default
Debug Mode: false
Plugins
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Docker Buildx (Docker Inc., v0.8.2-docker)
compose: Docker Compose (Docker Inc., v2.6.0)
scan: Docker Scan (Docker Inc., v0.17.0)
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 10
Server Version: 20.10.17
[...]
Kernel Version: 5.4.0-121-generic
Operating System: Linux Mint 20.2
OSType: linux
Architecture: x86_64
[...]
Additional environment details:
—

