Answer the question
In order to leave comments, you need to log in
How to run another command in docker?
I have a Dockerfile that starts with FROM php:7.4-fpm
and ends with CMD ["php-fpm"]
I need to additionally run the following command in it:
php /var/www/html/artisan queue:listen --memory=1024 --timeout=1800
CMD php-fpm && /usr/local/bin/php /var/www/html/artisan queue:listen --memory=1024 --timeout=1800
CMD php-fpm ; /usr/local/bin/php /var/www/html/artisan queue:listen --memory=1024 --timeout=1800
Answer the question
In order to leave comments, you need to log in
This is not considered a docker-way (it’s more correct to run a separate queue handler in a separate container), but you can do this:
one command & another command
. You can also make a script that starts everything as it should, and use it as a cmd. You can also inject a micro service management system like runit into the container.
Why is it considered wrong to do so? If php-fpm crashes, then the whole container will crash and may restart automatically. And if the second service falls, the container will work as if nothing had happened.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question