'Shutdown Postgres process in Docker but keep container alive?

I'm using the official Postgres Docker Image, namely postgres:12.9-alpine

I'd like to run docker container commit on a container whose Postgres process has been terminated gracefully.

When I attempt to run pg_ctl stop -D <datapath>, I do in fact shut down the Postgres process, but the container comes down with it.

Is it possible to keep the container alive so that I can commit the container to a new image in a clean state?



Solution 1:[1]

You can commit a new image from an exited container, so there's no need to keep it running. Just don't automatically remove the container on exit.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hans Kilian