Does docker-compose up destroy old database?

I am new with docker; I have a docker-compose.yml file. My question is: if I run docker-compose up after modifying this file, will this remove the old postgres db?

Upvotes: 1

Views: 9978

Answers (1)

jwodder
jwodder

Reputation: 57610

If the configuration for the PostgreSQL service or one of its dependencies has changed since the last time you ran docker-compose up, Docker Compose will destroy and recreate the container, but the new PostgreSQL container will continue to use the same volumes as the old one. If you're using the official postgres image (rather than an image you made yourself), all of the database's data will be stored in a Docker volume by default, and so the data will be preserved across invocations of docker-compose up (but not invocations of docker-compose rm postgres-service or docker-compose down).

Upvotes: 7

Related Questions