Docker Compose with one Terminating Container

I have a docker that configures the database container, an application container and one container that preloads the database with the necessary data.

I want to start all containers along with docker-compose up , while the preload container ends after it exit 0 with exit 0 .

But the completion of this one container removes the full setup with the message:

 composesetup_load_1 exited with code 0 Gracefully stopping... (press Ctrl+C again to force) Stopping composesetup_app_1... Stopping composesetup_db_1... 

Is there a way to have multiple containers with different lifetimes in a single docker setup? If so, how?

+7
docker docker-compose exit-code exit fig
source share
2 answers

My workaround for now is to load the preload container by adding tail -f /dev/null to the end of the script entry point. This makes the process work, but nothing happens.

+4
source share

Using the -d option in docker-compose up -d will start the process in separate mode. This avoids the need to kill the service with Ctrl + C and therefore stop the containers.

Note. I want you to kill the process with Ctrl + C from the message " Gracefully stopping... (press Ctrl+C again to force) " that you divided.

0
source share

All Articles