2

I have a Dockerfile with the lines:

ENTRYPOINT ["echo"]
CMD ["hello"]

When I run the exec command on an running container I expect:

docker exec -it running_container world
rpc error: code = 2 desc = oci runtime error: exec failed: exec: "world": executable file not found in $PATH

How can I make it echo world?

derrend
  • 4,176
  • 4
  • 27
  • 40

1 Answers1

3

You can

docker exec -it container_id echo hello

Keep in mind that docker exec just launches commands, like some

cat file

or

echo abc >> /etc/abc.def

or

sed regex file

or a shell

Docker exec has no relationship with the ENTRYPOINT or CMD of the Dockerfile

user2915097
  • 30,758
  • 6
  • 57
  • 59
  • "Docker exec has no relationship with the ENTRYPOINT or CMD of the Dockerfile" - Thank you, thatis what I was wondering. Do you happen to have a link to any docs per chance? – derrend Oct 10 '16 at 09:10
  • extract from https://docs.docker.com/engine/reference/commandline/exec/ `The docker exec command runs a new command in a running container.` just a command, any command, they never reference the ENTRYPOINT or the CMD – user2915097 Oct 10 '16 at 10:09