igorsantos07
igorsantos07

Reputation: 4686

Is it possible to run a command when stopping a Docker container?

I'm using docker-compose to organize containers for a JS application.
The source container sports command: npm start, pretty standard, to spin up the live application. However, that timeouts when I ask it to stop.

I was wondering if it's possible to have docker-compose stop to run a command inside the container - that could properly terminate the application.

Upvotes: 0

Views: 110

Answers (1)

Mateusz Moneta
Mateusz Moneta

Reputation: 1640

docker-compose stop just sends a SIGTERM to your container and if it does not stop after 10secs (configurable) SIGKILL follows. So if you want to customize this behavior, you should handle signal inside your entrypoint (if you have one).

Upvotes: 2

Related Questions