I have a simple docker-compose.yml file
version: '2'
services:
test:
image: centos:6.7
entrypoint: echo
command: echo From compose
Now below is the command i execute
[root@localhost test-compose]# docker-compose run test
echo From compose
[root@localhost test-compose]# docker-compose run test this is best
this is best
[root@localhost test-compose]# docker-compose run --entrypoint "" test /bin/bash
/bin/bash
[root@localhost test-compose]# docker-compose run --entrypoint /bin/bash test
/bin/echo: /bin/echo: cannot execute binary file
[root@localhost test-compose]# docker-compose run --entrypoint /bin/bash test ""
/bin/echo: /bin/echo: cannot execute binary file
As you can see I am not able to get into bash any how. I am using Docker 1.11.1. If any more is needed please let me know
Yes, it would make sense for the CLI to be able to override the value found in the compose file.
Thank you for the report.
@shin, It's not an enhancement. It's mostly a bug i guess. Because the feature is listed in --help
[root@localhost pp21]# docker-compose run --help
Run a one-off command on a service.
For example:
$ docker-compose run web python manage.py shell
By default, linked services will be started, unless they are already
running. If you do not want to start linked services, use
`docker-compose run --no-deps SERVICE COMMAND [ARGS...]`.
Usage: run [options] [-p PORT...] [-e KEY=VAL...] SERVICE [COMMAND] [ARGS...]
Options:
-d Detached mode: Run container in the background, print
new container name.
--name NAME Assign a name to the container
--entrypoint CMD Override the entrypoint of the image.
-e KEY=VAL Set an environment variable (can be used multiple times)
-u, --user="" Run as specified username or uid
--no-deps Don't start linked services.
--rm Remove container after run. Ignored in detached mode.
-p, --publish=[] Publish a container's port(s) to the host
--service-ports Run command with the service's ports enabled and mapped
to the host.
-T Disable pseudo-tty allocation. By default `docker-compose run`
allocates a TTY.
-w, --workdir="" Working directory inside the container
@shin- , Thoughts on this?
+1
OK, I think we do have a bug here. When --entrypoint
is passed to docker run
, the container's Cmd
is emptied out, even if the image sets a default. We should do the same with docker-compose run
.
There's an additional bug where passing ""
as the command is equivalent to passing nothing at all.
I've fixed both in https://github.com/docker/compose/pull/3718.
[36mdb |[0m /usr/bin/tail: /usr/bin/tail: cannot execute binary file
I don't think you did, thou ;)
Docker version 1.12.2, build bb80604, experimental
docker-compose version 1.8.1, build 004ddae
@aanand can it be that this issue resurfaced? I'm having this exact issue, but I can't even override the entrypoint by giving the --entrypoint CMD
arugment.
Docker version 17.03.1-ce, build c6d412e
docker-compose version 1.11.2, build dfed245
@JanBrinker Can you share your Compose file, the OS you're running on, and the exact command you're running + output so we can investigate?
Sorry for bothering. I discovered it was a bad configuration on my end. I'm not very deep in docker and docker-compose yet. But thanks for asking :)
How did you solve this, @JanBrinker? I'm facing the same issue with Docker version 17.03.1-ce, build c6d412e.
Most helpful comment
How did you solve this, @JanBrinker? I'm facing the same issue with Docker version 17.03.1-ce, build c6d412e.