I set up a Github codespaces environment using devcontainer.json
and docker-compose.yaml
. Everything works fine, but the postgres database defined in docker-compose.yml
loses its data every time the container needs to be re-built.
Here's the bottom part of the docker-compose.yml
db:
image: postgres:latest
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: test_user
POSTGRES_DB: test_db
POSTGRES_PASSWORD: test_pass
volumes:
postgres-data:
as you can see, I am trying to map the postgres data volume into a postgres-data
volume, but this doesn't work for some reason.
What am I doing wrong that's preventing postgres data from persisting between container builds?
external: true
? – Runabout