I’m trying to make a multistage Dockerfile that has a stage for testing. When I run the container, after the command end the container didn’t stop.
My expectation is, I will have a testing stage that will be use to run PHPUnit command inside the docker, that stage is only going to be used as a helper and after it run it will exit automatically. But for some reason the container never exit even after the command end.
This is my Dockerfile snippet:
FROM php:8.2-fpm AS final
WORKDIR /var/www/html
# Do some setup here
FROM final AS tester
RUN pecl install pcov
&& echo "extension=pcov.so" >> /usr/local/etc/php/php.ini
RUN echo "alias ppc='php artisan test --parallel --coverage --coverage-text'" >> ~/.bashrc
ENTRYPOINT []
CMD ["/bin/bash", "-c", "php artisan test --parallel --coverage --coverage-text"]
2
Answers
You may try to add this at the end of the command:
Remove ENTRYPOINT [] in the tester stage and update the CMD as follows: