Reputation: 86
I have multiple Amazon Linux 2 boxes acting as Docker hosts, as the instances are needed Mon-Fri 9am-5pm, in an effort to save costs Shutdown tags that allow specific stop/start times have been implemented. I'm concerned that issuing stop-instances isn't gracefully shutting down the containers and may lead to volume corruption.
How can I make it so that when stop-instances is issued, the docker host is able to react and issue docker-compose down and then on instance startup issue docker-compose up -d?
Upvotes: 2
Views: 2622
Reputation: 6340
When the stop-instances
is issued, a graceful shutdown is triggered by the ACPI shutdown button press event from the hypervisor.
The OS has four minutes, before a hard shutdown is performed.
I have zero experience with Amazon Linux 2
but I assume that systemd
handles the graceful shutdown of the system.
You can add run the docker-compose up/down
in a start-up respectively shutdown-script.
Running a start-up script is already described in this post.
Running a shutdown-script is already described in this post.
Upvotes: 1