Docker Compose with one Terminating Container

I'm having a docker compose setup of a database container, an application container and one container which pre-loads the database with necessary data.

I want to start all of the containers together with docker-compose up while the pre-loading container terminates after it has completed it work with exit 0 .

But terminating this one container takes down the complete 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 any way of having multiple containers with different life-time in one docker-compose setup? If yes, how?


My workaround for now is to keep the pre-loading container running by adding tail -f /dev/null to the end of the entrypoint script. This keeps the process running, while nothing actual happens.


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

Note: I am asumming you killed the process with Ctrl+C from the message " Gracefully stopping... (press Ctrl+C again to force) " you shared.

链接地址: http://www.djcxy.com/p/85668.html

上一篇: BEHIND不适用于Android 5.x(棒棒堂)

下一篇: Docker撰写与一个终止容器