4

I need to run docker-compose with two containers,- php-fpm and php-cli. Although I need another container with composer.

When I run docker-compose up -d - container with php-cli become always restarting and composer container just stops.

troitskyA
  • 103
  • 2
  • 7

1 Answers1

9

PHP cli is not running in daemon mode. You run it, and then it stops. Next, Docker tries to restart it (you've set restart: always policy for php-cli). :)

IMO php-cli and composer services are redundant. You can use php service for your needs. Simply run docker-compose run php php [path to script]

radmen
  • 1,584
  • 9
  • 13
  • 1
    "IMO php-cli and composer services are redundant. You can use php service for your needs." Not disagreeing, but why do you believe this? What's the difference between Docker `php`, Docker `php-cli` and Docker `php-fpm`, see also question, here: https://devops.stackexchange.com/questions/9505/what-is-the-difference-between-php-cli-and-php-fpm-why-2-php-variants-and-why-c – therobyouknow Oct 21 '19 at 14:22
  • @therobyouknow the `php-fpm` docker image can handle all of the required things: running script in CLI mode and running composer (ie via the phar archive). – radmen Oct 22 '19 at 15:39