1

I am using docker desktop 4.17.1 on windows 11 and I needed to save my db data on host machine.

I used "./postgres_data:/var/lib/postgresql" volume and it created a folder postgres_data/data in my project's directory, but this folder was empty, and when I created tables in my db and deleted containers with docker compose down, docker compose up started containers like they were new and empty. When I started to use "./postgres_data:/var/lib/postgresql/" everything became ok, but I still want to understand why it works so. Simple examples of postgres_data content below

postgres_data when volume with /datapostgres_data when volume without /data

shameoff
  • 61
  • 5
  • 1
    The mount point in the container must be `/var/lib/postgresql/data` and not a parent directory. I'll add a description of this mechanism to the linked question. – David Maze May 10 '23 at 10:53
  • Do I need to delete the question in this case or I should leave my question there? Thank you for reply! – shameoff May 10 '23 at 14:23

0 Answers0