Reputation: 17467
I use the docker run genezys/gitlab:7.5.2
command to create and start a container:
[root@localhost ~]# docker run genezys/gitlab:7.5.2
/opt/gitlab/embedded/bin/runsvdir-start: line 34: ulimit: max user processes: cannot modify limit: Operation not permitted
/opt/gitlab/embedded/bin/runsvdir-start: line 37: /proc/sys/fs/file-max: Read-only file system
[2015-05-05T05:43:02+00:00] INFO: Forking chef instance to converge...
......
I can see there are logs outputted in terminal.
But when I use docker run genezys/gitlab:7.5.2 /bin/true
command:
[root@localhost ~]# docker run genezys/gitlab:7.5.2 /bin/true
[root@localhost ~]#
There is no logs outputted.
Why is there no logs using docker run image command
to start container?
Upvotes: 2
Views: 376
Reputation: 1323973
That would be because the /bin/true
CMD (from docker run genezys/gitlab:7.5.2 /bin/true
) overwrites the original CMD defined in the Dockerfile:
# Default is to run runit & reconfigure
CMD ["/usr/local/bin/gitlab.sh"]
Since GitLab is never run (with /bin/true
), it never outputs any log.
The docker run
has a COMMAND
parameter:
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
The docker run "Overriding Dockerfile image defaults" mentions:
Four of the Dockerfile commands cannot be overridden at runtime:
FROM
,MAINTAINER
,RUN
, andADD
.
Everything else has a corresponding override indocker run
.
That includes CMD
:
Recall the optional
COMMAND
in the Docker commandline:
$ sudo docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]
This command is optional because the person who created the IMAGE may have already provided a default
COMMAND
using the DockerfileCMD
instruction.
As the operator (the person running a container from the image), you can override thatCMD
instruction just by specifying a newCOMMAND
.If the image also specifies an
ENTRYPOINT
then theCMD
orCOMMAND
get appended as arguments to theENTRYPOINT
.
Upvotes: 3