I want to execute the following command in docker-compose.yml
composer install --no-interaction
tail -f /dev/null
What composer install is installed in vendor may change depending on the contents of json If you build a container in an environment where composer install is executed with Dockerfile, it is very troublesome because you need to recreate it from the image after editing json.
Also, if the local directory is mounted on the container, it will be as follows Image creation-> Mount-> There is no vendor directory locally-> After mounting, the vendor in the image disappears
reference: https://teratail.com/questions/203319
command: tail -f /dev/null
By the way, the above command is not started only by building the container just by docker-compose up -d normally (to be exact, the container stops after all the contents described in yml are completed), so it is described in yml. The container does not stop if some command is being executed even after the contents are finished. From the specification, the container is prevented from stopping by executing a command that continues to operate such as tail -f.
reference: https://teratail.com/questions/280776
command: >
sh -c "
composer install --no-interaction &&
tail -f /dev/null
"
When I entered the docker container, I did not understand the difference between bash and sh, so I reviewed it.
man sh
Then DASH came out
An abbreviation for Debian Almquist shell, it seems to be faster than bash. There was also a description that it was an alternative to/bin/sh, but it seems that it will take time to dig deeper into why it is being substituted, so at another time.
https://ja.wikipedia.org/wiki/Debian_Almquist_shell
Recommended Posts