Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tomcat docker container stop and exit after stop tomcat server

I am using docker container/image here. After running the docker container, everything is OK. but if I run /usr/local/tomcat/bin# ./catalina.sh stop or /usr/local/tomcat/bin# ./shutdown.sh, the running docker container will stop and exit.

Why? How to change it?

Thanks. Any comment welcomed.

like image 240
BAE Avatar asked Aug 11 '17 18:08

BAE


People also ask

Why does my docker container keep exiting?

Why docker container is exited immediately? You're running a shell in a container, but you haven't assigned a terminal: If you're running a container with a shell (like bash ) as the default command, then the container will exit immediately if you haven't attached an interactive terminal.

How do I keep my docker container running?

The simplest way to keep the container running is to pass a command that never ends. We can use never-ending commands in any of the following ways: ENTRYPOINT or CMD directive in the Dockerfile. Overriding ENTRYPOINT or CMD in the docker run command.

How do I stop docker container from running in the background?

Stop YouTrack docker container For a graceful shutdown, you can also use the standard ` docker kill --signal=SIGTERM <containerId> ` command.

How do I force stop a docker container?

docker rm -f The final option for stopping a running container is to use the --force or -f flag in conjunction with the docker rm command. Typically, docker rm is used to remove an already stopped container, but the use of the -f flag will cause it to first issue a SIGKILL.


1 Answers

This is by definition, see https://github.com/docker-library/tomcat/blob/master/Dockerfile.template in which the latest line is CMD ["catalina.sh", "run"]

Once you manually do catalina stop you cause the above CMD to terminate, hence the container stops.

like image 190
ShaharT Avatar answered Nov 14 '22 22:11

ShaharT