Answer the question
In order to leave comments, you need to log in
Docker on windows not working volumes?
Help with the docker to understand if anyone is in the subject. In general, he collected the config for understanding. As a result, everything seems to work, but it does not save data in postgres. More precisely, here's what's going on.
postgres:
container_name: symfony-postgres
image: postgres:12
volumes:
- ./docker/postgres:/var/lib/postgres
restart: always
environment:
POSTGRES_DB: db
POSTGRES_USER: user
POSTGRES_PASSWORD: secret
ports:
- 15432:5432
volumes:
postgres:
"Mounts": [
{
"Type": "bind",
"Source": "E:\\projects\\repo\\docker\\postgres",
"Destination": "/var/lib/postgres",
"Mode": "rw",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "volume",
"Name": "ded9c7006aa1cd122783b4fb0503fe97e6b6180ddc68885184e3e4e4c75d999f",
"Source": "/var/lib/docker/volumes/ded9c7006aa1cd122783b4fb0503fe97e6b6180ddc68885184e3e4e4c75d999f/_data",
"Destination": "/var/lib/postgresql/data",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
Answer the question
In order to leave comments, you need to log in
since you are explicitly specifying a directory on the host, this is not a volume, but a bind mount. When using bind mount, the config section volumes
(at the top level) is not needed. You can delete it. Moreover, you still write it incorrectly. But you don’t have files, because you are specifying the wrong directory in the container. Need /var/lib/postgres ql /data
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question