Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is it required to run the true command when you create a data-only container in Docker?

Tags:

docker

I was reading some of the Docker documentation and I've noticed that they pass the true command when they create a container.

$ sudo docker create -v /dbdata --name dbdata training/postgres /bin/true

Why are they passing /bin/true to the container? If I understand correctly, my data-only container is never running, so is that even necessary?

like image 678
425nesp Avatar asked May 12 '15 19:05

425nesp


1 Answers

It is not necessary to run the command, but for right now Docker does require you to specify a command to run (or at least an entrypoint). I guess this is for schema-completeness reasons. The following command will create a docker container successfully:

docker create -v /dbdata --name dbdata --entrypoint=_ scratch

That container can be used as a volume container, but it can never run.

That said, many Docker utilities (such as Compose) expect a command to exist, because they will use run, not just create internally.

If you want to make very small containers for DVC purposes, use very small static binaries such as tianon/true.

like image 123
kojiro Avatar answered Oct 17 '22 05:10

kojiro