简体   繁体   中英

Docker Postgres data volume on the host

I've a simple tiny issue. I have an app (ASPNET Core) and db (Postgres). I run the container of the db first and then run the app container so that the app can discover the db at runtime. Now I can connect the Postgres database using pgAdmin tool (On Windows) and everything works fine.

Now if I run the Postgres container with a data volume command like:

docker run -p 5432:5432 -d -v pg-data:/var/lib/postgresql/data --network=isolated_network --name postgres -e POSTGRES_PASSWORD=5432 postgres

Here, I can connect to Postgres instance running in the container and I get my data there. Here I have the question that where the data volume pg-data is available on the host?

Moreover, if I mount my Windows directories to the Docker Engine and run the command:

docker run -p 5432:5432 -d -v d:/data:/var/lib/postgresql/data --network=isolated_network --name postgres -e POSTGRES_PASSWORD=5432 postgres

I do see the data folder on in the D:\\ drive but I can't connect to this instance of the Postgres container with pgAdmin tool and my app stops working.

In linux default location of volume is:

/var/lib/docker/volumes

For windows i am not sure. but you can inspect container that will give you path and all details that you want.

docker inspect containername

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM