Docker Community Forums

Share and learn in the Docker community.

[solved] Keeping the container alive after killing the process launched by the entrypoint

Hi all

I made a container and here you have the most relevant parts:

FROM archlinux:latest
RUN pacman -Sy      \
    --noconfirm     \
    jdk11-openjdk wget bzip2
ENV PATH="/neo4j-community-4.2.4/bin:"${PATH}
RUN neo4j-admin load --from=/neo4j.dump --database=neo4j --force
ADD ./ /
RUN chmod 755 /

Then in the entrypoint:

neo4j console

My problem is

  1. I launched the container then began developing (without volume…)
  2. I need to dump the data
  3. I cant dump a running database…
  4. I need to stop the “neo4j console” process, but this will kill the container…

How can I dump my database?
Thank you for you help

If you would like to keep your container running in detached mode, you need to run something in the foreground. An easy way to do this is to tail the /dev/null device as the CMD or ENTRYPOINT command of your Docker image. This command could also run as the last step in a custom script used with CMD or ENTRYPOINT .

Yes, but in my current situation, what solution would you recommend?

I found a way to solve it.

Runing container, enter it with “docker exec […] /bin/bash”:

  1. Install “supervisor”
  2. Configure supervisor to launch “neo4j console”
  3. Edit the “/” script to launch “supervisor” instead of directly “neo4j console”

Then exit the container

  1. “docker commit” to save the state
  2. “docker stop” the container
  3. “docker start”, will re launch the “/”

Enter again in the container:

  1. “supervisorctl stop neo4j” to stop the database
  2. note that the container is still alive because “supervisord” is still running
  3. “neo4j-admin dump […] /dump-location.dump”

Then exit the container

  1. “docker copy container-name:/dump-location.dump /dump-location.dump”