Why is it necessary to run this command when creating a data-only container in Docker?

I read some of the Docker documentation , and I noticed that they pass the true command when creating the container.

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

Why do they transfer /bin/true to the container? If I understand correctly, my data-only container never starts, and is this even necessary?

+6
source share
1 answer

There is no need to run this command, but now Docker requires you to specify the command to run (or at least the entry point). I assume this is due to the principles of the scheme. The following command will successfully create a docker container:

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

This container can be used as a volume container, but it can never work.

However, many Docker utilities (such as Compose) expected the command to exist because they would 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 .

+5
source

Source: https://habr.com/ru/post/987087/


All Articles