Answer the question
In order to leave comments, you need to log in
How to start a background process (worker) inside a docker container so that it runs reliably and restarts when necessary?
Hello! I make a worker on Symphony, all work goes through the docker. Accordingly, the worker is launched in a separate container. RabbitMQ is used as a transport. Now there is a problem: in order for the worker to work normally, I go to the console of the running container and run the command manually:
php bin/console messenger:consume amqp_image_caching -vv
CMD ["php bin/console messenger:consume amqp_image_caching -vv"]
FROM php:7.4-fpm
RUN apt-get update && apt-get install -y zlib1g-dev g++ git libicu-dev zip libzip-dev zip \
&& docker-php-ext-install intl opcache pdo pdo_mysql \
&& pecl install apcu \
&& docker-php-ext-enable apcu \
&& docker-php-ext-configure zip \
&& docker-php-ext-install zip
# AMQP
RUN docker-php-ext-install sockets
RUN apt-get install -y librabbitmq-dev \
&& pecl install amqp \
&& docker-php-ext-enable amqp
RUN apt-get install -y inetutils-ping
# GD
RUN apt-get update -y && apt-get install -y libwebp-dev libjpeg62-turbo-dev libpng-dev libxpm-dev \
libfreetype6-dev
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
--with-webp
RUN docker-php-ext-install gd
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN curl -sS https://get.symfony.com/cli/installer | bash
RUN mv /root/.symfony/bin/symfony /usr/local/bin/symfony
WORKDIR /var/www/project
CMD ["php bin/console messenger:consume amqp_image_caching -vv"]
Answer the question
In order to leave comments, you need to log in
Try to specify the full path to the php binary and separately give parameters:
CMD ["/usr/local/bin/php", "bin/console", "messenger:consume", "amqp_image_caching", "-vv"]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question