Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I understand the role of "/bin/true" command in "docker run ..." command?

Tags:

docker

gitlab

I am following this document to install gitlab docker image, and get confused with the command:

docker run --name gitlab_data genezys/gitlab:7.5.2 /bin/true

I know "/bin/true" command just returns a success status code, but how can I understand the role of /bin/true in this docker run ... command?

like image 303
Nan Xiao Avatar asked Apr 21 '15 03:04

Nan Xiao


People also ask

What does run command do in docker?

The docker run command creates a container from a given image and starts the container using a given command. It is one of the first commands you should become familiar with when starting to work with Docker.

Which command is used to view the running processes of a container in docker?

Like it was mentioned, if you are already inside of a container, then just use ps -eaf command to see the running processes.

How do I run a command in a docker container?

Running Commands in an Alternate Directory in a Docker Container. To run a command in a certain directory of your container, use the --workdir flag to specify the directory: docker exec --workdir /tmp container-name pwd.

Can you tell the what are the purposes of up run and start commands of Docker compose?

The run command acts like docker run -ti in that it opens an interactive terminal to the container and returns an exit status matching the exit status of the process in the container. The docker compose start command is useful only to restart containers that were previously created, but were stopped.


1 Answers

Running and thus creating a new container even if it terminates still keeps the resulting container image and metadata lying around which can still be linked to.

So when you run docker run ... /bin/true you are essentially creating a new container for storage purposes and running the simplest thing you can.

In Docker 1.5 was introduced the docker create command so I believe you can now "create" containers without confusingly running something like /bin/true

See: docker create

This is new method of managing data volume containers is also clearly documented in the section Creating and mounting a Data Volume Container

like image 183
James Mills Avatar answered Oct 24 '22 18:10

James Mills