Skip to content
Advertisement

docker entrypoint sh file restarting

I am testing docker with my php project. Everything is ok in testing but if I add ENTRYPOINT, docker is restarting.

Here is my docker compose file

JavaScript

Dockerfile

JavaScript

start-container.sh file

JavaScript

I also print log for that docker image.

JavaScript

I think my error is docker container is restarting after running start-container.sh file. When I google, some people use PHP artisan script with ENTRYPOINT sh file.

What should I do not to restart again and again with ENTRYPOINT sh file?

Advertisement

Answer

Your entrypoint script ends with the line exec "$@". This runs the image’s CMD, and is generally a best practice. However, your image doesn’t have a CMD, so that command just expands to a bare exec, which causes the main container process to exit.

An image built FROM php:fpm often won’t have a CMD line since the base image’s Dockerfile specifies CMD ["php-fpm"]; it is enough to COPY your application code into a derived image, and the base image’s CMD knows how to run it. However, setting ENTRYPOINT in a derived image resets the CMD from the base image (see the note in the Dockerfile documentation discussing CMD and ENTRYPOINT together). This means you need to repeat the base image’s CMD:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement