I am using Windows 10 with WSL2. I'm running docker-compose through Visual Studio 2022.
I have the following docker-compose.yml file:
version: '3.4'
services:
dbService:
image: postgres
volumes:
- PostgresUsers:/var/lib/postgresql/data
restart: always
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
ports:
- "5432:5432"
pgadmin:
container_name: pgadmin
image: dpage/pgadmin4
restart: always
environment:
PGADMIN_DEFAULT_EMAIL: admin@admin.com
PGADMIN_DEFAULT_PASSWORD: root
ports:
- "5050:80"
depends_on:
- dbService
volumes:
PostgresUsers:
If I create tables and insert data into a created database in my postgres service, shutdown and delete the 2 running containers, and create them again, no data is persisting. Put another way, when I register a Server and check the Databases in that server in pgAdmin, none of the previously entered data is present.
I've checked my Docker volumes directory in the hidden wsl$ drive here:
\\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes
and am seeing that each time I run docker-compose through Visual Studio, new volumes that are not the name I specified are being created, ones that appear to have a random string of what I'm assuming is the Docker Container's ID or some other related value
How can I make data entered in Postgres persist after shutting down and deleting the running containers?