Skip to content

Instantly share code, notes, and snippets.

@jkeam
Last active July 31, 2025 01:49
Show Gist options
  • Save jkeam/225a4e8619fcac86d0b510ba309f0635 to your computer and use it in GitHub Desktop.
Save jkeam/225a4e8619fcac86d0b510ba309f0635 to your computer and use it in GitHub Desktop.
Podman share directory
#!/bin/bash
# create dir for container
mkdir -p /tmp/work
# give permissions to container user
podman unshare chown -R 1001:1001 /tmp/work
# relabel
sudo semanage fcontext -a -t container_file_t '/tmp/work(/.*)?'
sudo restorecon -Rv /tmp/work
# list
sudo semanage fcontext --list
# delete label
sudo semanage fcontext -d '/tmp/work(/.*)?'
@jkeam
Copy link
Author

jkeam commented Jan 25, 2023

Or for temporary only:

mkdir -p /tmp/work
podman unshare chown -R 1001:1001 /tmp/work
sudo chcon -Rt container_file_t /tmp/work

@jkeam
Copy link
Author

jkeam commented Jul 31, 2025

Another great link here:
https://blog.christophersmart.com/2021/01/31/podman-volumes-and-selinux/

podman run -dit --volume ~/src:/dest:z --name busybox busybox
podman exec -it busybox touch /dest/file

and then from the host:

ls -Z ./src/file
# returns this:
#   system_u:object_r:container_file_t:s0 ./src/file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment