PostgreSQL docker container in Widnows

I am trying to run a Docker PostgresSQL container on my windows machine and am mounting a data volume using the following command:

docker run -p 5432:5432 -it --volume c:\Users\me\Desktop\pg\data\:/var/lib/postgresql/data postgres:latest -e POSTGRES_USER=user POSTGRES_PASSWORD=password

      

However, I keep getting a list of allowed rights when the container tries to deploy:

chown: changing ownership of ‘/var/lib/postgresql/data/pg_log’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_logical/mappings’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_logical/snapshots’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_logical’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_multixact/members/0000’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_multixact/members’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_multixact/offsets/0000’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_multixact/offsets’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_multixact’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_notify/0000’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_notify’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_replslot’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_serial’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_snapshots’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_stat’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_stat_tmp/db_0.stat’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_stat_tmp/db_16395.stat’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_stat_tmp/global.stat’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_stat_tmp’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_subtrans/0000’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_subtrans’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_tblspc’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_twophase’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/PG_VERSION’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_xlog/00000001000000000000000A’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_xlog/00000001000000000000000B’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_xlog/archive_status’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_xlog’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/postgresql.auto.conf’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/postgresql.conf’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/postmaster.opts’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/postmaster.pid’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data’: Permission denied

      

Can someone point out what I am doing wrong?

Thanks in advance.

+3


source to share


3 answers


This is a known limitation in Docker for Windows. The semantics of mapping a Linux ↔ Windows file system from a Windows directory to a Linux directory is imperfect because mount is performed using CIFS / SMB. One of the things that won't work is chown

(changing ownership) because that can't be mapped to your Windows filesystem.



You should use a named volume instead. This forum post has details: https://forums.docker.com/t/data-directory-var-lib-postgresql-data-pgdata-has-wrong-ownership/17963/24?u=friism

+4


source


Are you using docker with hyper-v or docker-toolbox? Since, in my experience, I only used docker-toolbox (it uses a docker machine), and in order to display the volume correctly using -volume or -v (same thing), you must put this nomenclature for the Win path:

docker run -p 5432:5432 -it -v /c/Users/me/Desktop/pg/data:/var/lib/postgresql/data postgres:latest -e POSTGRES_USER=user POSTGRES_PASSWORD=password

      



Not sure if this can help. Your problem may be related to the path for the displayed volume. Good luck!

+1


source


Here is a docker container I made that works on Windows. This might help you.

https://cloud.docker.com/swarm/dragnet/repository/docker/dragnet/postgres-windows/general

Source code here: https://github.com/PaulDMendoza/Docker-Postgres-Windows

0


source







All Articles