Docker Community Forums

Share and learn in the Docker community.

Container exits due to the Entrypoint Shell script


I have to run a shell script to create the DB tables when the container starts but it causes the container to exit otherwise it works fine.

Following is the last instruction in the DockerFile:

ENTRYPOINT ["/var/www/"]

I added the exec /bin/bash; command at the end of the script but the application does not run in the browser.

  • How can I debug what is happening to fix the issue?
  • How can I keep the container running with the script so that the application also runs in the browser?


You don’t tell us what your script does, but let me guess: it executes some commands and then exits. As soon as there is no process running in the foreground, the container has nothing more to do and is terminated. This means after your script has done its work it has to start your application in the foreground.

1 Like