16

I find when using docker run I sometimes don't need to add a "command", while sometimes a "command" is a must. E.g. when running the ubuntu image a command isn't required:

# docker run ubuntu
#

While when running mstormo/suse:

# docker run mstormo/suse
Error response from daemon: No command specified
# docker run mstormo/suse bash
#

So is this related to the specified image?

timlyo
  • 2,086
  • 1
  • 23
  • 35
Nan Xiao
  • 16,671
  • 18
  • 103
  • 164

1 Answers1

26

The Docker image can optionally include a default command to run when none is given on the command-line.

If no default command is given, then it has to be provided by the caller.

If you look at the Dockerfile for ubuntu, they have

CMD ["/bin/bash"]

So if you don't say otherwise, it will run bash for you.

No such setting in mstormo/suse.

Community
  • 1
  • 1
Thilo
  • 257,207
  • 101
  • 511
  • 656
  • 1
    So although from [docker run](https://docs.docker.com/v1.8/reference/commandline/run/) page:`docker run [OPTIONS] IMAGE [COMMAND] [ARG...]`, the command seems **optional**, but actually it should be **must**, right? – Nan Xiao Mar 17 '16 at 05:27
  • Well, as far as docker is concerned, it is optional. But the image may want one (and it may also want some args). – Thilo Mar 17 '16 at 05:30
  • The error you are getting about the missing command is not coming from docker. It is coming from the entrypoint binary inside of the image. – Thilo Mar 17 '16 at 05:30