0

I am trying to get Postgres container running on my Windows 10 machine with Podman on wsl2.

The command I am using is

podman run -d --name test-postgres -e POSTGRES_USER=admin -e POSTGRES_PASSWORD=admin  -p 5432:5432 -v D:\test\postgres:/var/lib/postgresql/data  docker.io/library/postgres

I get the following error in container logs

chmod: changing permissions of '/var/lib/postgresql/data': Operation not permitted

It probably needs some mapping via -uidmap ? However in wsl I can't find the /etc/subuid file. The explanation on the documentation of how to use it also not very clear, I couldn't find anything which is trying to explain this from a Windows host OS perspective.

I am running Podman machine in rootless mode. How can I proceed?

1 Answer 1

0

I have tried various things. In essence the mount points should be available inside your podman-machine-defualt vm running linux. By default all windows drives are mounted as read only. logged into the podman-machine-default using

wsl -d podman-machine-default

then list the mounted drives using

ls -la /mnt 

you should see the drives listed there so if for example you wanted to mount a read only d:/mount_volumes/postgres on your windows as the data directory for your postgres container you could create an container

podman run -d --name postgres-a -e POSTGRES_USER=admin -e POSTGRES_PASSWORD=admin  -p 5432:5432 -v /mnt/d/mount_volumes/postgres:/var/lib/postgresql/data  docker.io/library/postgres

however since write permissions are required the above does not work.

some posts suggest starting the container with the same user passing --user option in above podman run command however that did not work for me. was not sure if the linux mount owner id has to be used or postgres container running with an id has to be used which was found via 'podman run --rm postgres id postgres' still have to dig into what that command does.

what worked for me finally was:

create named volume

podman volume create pgdata

then use the following command to create postgres container.

podman run -d --name postgres-a -e POSTGRES_USER=admin -e POSTGRES_PASSWORD=admin  -p 5432:5432 -v pgdata:/var/lib/postgresql/data  docker.io/library/postgres

login via

 podman exec -it postgres-a psql -h localhost -p 5432 -U admin 

you can inspect volume using

podman volume inspect pgdata 

the above still does not give me control to create the data directories in a specific directory but at least its persistent on windows host machine.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.