How do I give (rootless) podman permissions to a ~/directory?

There are plenty of questions about permissions and podman but I cannot wrap my head around answers to those, could you please give me a noob answer on how to get this working?

I run
podman run --rm --name tilemill -t -p 20009:20009 -p 20008:20008 -v ~/Documents/MapBox:/root/Documents/MapBox -e PGHOST=postgis -e PGDATABASE=gis -e PGUSER=docker -e PGPASSWORD=docker localhost/osm-bright

but I get errors like these
[tilemill] { Error: EACCES: permission denied, mkdir '/root/Documents/MapBox/export'

I tried to chmod 777 ~/Documents/MapBox but that’s not enough.

Hello @omichalek,
If you are on Silverblue then you cannot mkdir '/root/Documents/MapBox/export' because that is part of the immutable area of the filesystem.

I thought that command should be mapping it to ~/Documents/MapBox shouldn’t it? Confirmed also by that after creating the dir inside Documents, the error changed.

Sorry, I was mistaken, you are right this should be volume mounting the ~/Documents/MapBox as /root/Documents/MapBox of the container, my bad for not reading carefully enough. I will have to check this a bit more, be back soon.

1 Like

@omichalek try with :z at the end of the volume’s path:

podman run --rm --name tilemill -t \
  -p 20009:20009 \
  -p 20008:20008 \
  -v ~/Documents/MapBox:/root/Documents/MapBox:z \
  -e PGHOST=postgis \
  -e PGDATABASE=gis \
  -e PGUSER=docker \
  -e PGPASSWORD=docker \
  localhost/osm-bright

The volume part:

-v ~/Documents/MapBox:/root/Documents/MapBox:z

This has to do with the SELinux labels. Here you’ve some info about it:

By default, Silverblue has SELinux actived, so it can be a bit confusing the whole label thing and permissions. I’m still trying to wrap my head around that, but basically the issue is the labels.

NOTE: Be aware that after run that command the SELinux context labels will change for that directory (inside, but also outside the container). If the directory is for the container it’s ok, but change your entire HOME or a directory that need specific label, might give you some headaches.

To check the labels you can run:

ls -Z ~/Documents/

The flag -Z will show you the labels. Do it before and after running the podman command and you’ll see the difference.
At first, you’ll see something like:

 unconfined_u:object_r:user_home_t:s0   MapBox

After the podman run it will looks like:

 system_u:object_r:container_file_t:s0  MapBox

Anyway, it should work for your case. I hope it helps.

1 Like

the lower case z works, thank you very much!

1 Like