1

I'm start to dockerize a Linux Application and to do that I wrote a Dockerfile that:

  • Extract the application TAR file into a directory.
  • Execute the "entrypoint.sh"

the "entrypoint.sh":

  • Check if the application is already installed.
  • If the application is not installed, execute the installation script.

After that the container stops because the application run a background service.

Since I'm relative new to dockerize application, how can I prevent the container to stop?

Thanks for the help!

Federico
  • 1,117
  • 6
  • 20
  • 37
  • your can review [this post](https://stackoverflow.com/questions/41555884/docker-what-does-docker-run-restart-always-actually-do#:~:text=Restart%20policies&text=Always%20restart%20the%20container%20regardless,current%20state%20of%20the%20container.) docker run --always – zafer durkut Jan 25 '21 at 19:31
  • Make its `CMD` run a process that doesn't exit. The container will exit exactly when its main process does. The main process needs to run in the foreground. – David Maze Jan 25 '21 at 19:47
  • Does this answer your question? [How to keep Docker container running after starting services?](https://stackoverflow.com/questions/25775266/how-to-keep-docker-container-running-after-starting-services) – timsmelik Jan 25 '21 at 19:50

2 Answers2

3

Use ENTRYPOINT ["tail", "-f", "/dev/null"] at the end of your Dockerfile.

Romany
  • 31
  • 4
0

You need to detach the session so that it can run in the background:

docker run -dt image

e god
  • 96
  • 8