1

I plan to start a separate container (via compose) which configures my mongodb replica set. After configuration (via entrypoint sh script) the container is not needed anymore. Whats the best way to kill/stop him from shell?

robert
  • 797
  • 3
  • 9
  • 23
  • 1
    Maybe the `--rm` option is what you're searching for, see, e.g., https://docs.docker.com/compose/reference/run/ – fl9 Apr 24 '18 at 13:13
  • looks interesting, thanks. but that means i have to start all containers in compose file separatly because there is one which needs --rm option? – robert Apr 24 '18 at 13:26
  • Yeah, I think so...I would run the setup before with the `--rm` option and then start all services like `docker-compose up service_1 service_2 ...` This could also be of interest to you https://stackoverflow.com/questions/47207616/auto-remove-container-with-docker-compose-yml (Auto remove container with docker-compose.yml) – fl9 Apr 24 '18 at 13:36
  • The container will stop (exit) as soon as your Entrypoint script exit, say when it finishes its execution. You don't need any special for this. – Robert Apr 24 '18 at 14:06

1 Answers1

2

Whatever is launched first by the entrypoint command will be PID 1 in the Container. When PID 1 exits/stops, the Container will stop.

Good luck.

Jamie Bisotti
  • 2,605
  • 19
  • 23