Skip to content

Instantly share code, notes, and snippets.

@trevor-vaughan
Created March 30, 2022 22:40
Show Gist options
  • Save trevor-vaughan/5be6c00e15731e94c66e8a0f73069d42 to your computer and use it in GitHub Desktop.
Save trevor-vaughan/5be6c00e15731e94c66e8a0f73069d42 to your computer and use it in GitHub Desktop.
Podman with non-root GUI
#!/bin/bash
args="${@}"
container=<container>:<release>
uid=$( podman run --rm -it $container id -u | tr -d [:space:] )
gid=$uid
subuidSize=$(( $(podman info --format "{{ range .Host.IDMappings.UIDMap }}+{{.Size }}{{end }}" ) - 1 ));
subgidSize=$(( $(podman info --format "{{ range .Host.IDMappings.GIDMap }}+{{.Size }}{{end }}" ) - 1 ));
podman run \
-it \
--rm \
-e DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix:ro \
--uidmap $uid:0:1 \
--uidmap 0:1:$uid \
--uidmap $(($uid+1)):$(($uid+1)):$(($subuidSize-$uid)) \
--gidmap $gid:0:1 \
--gidmap 0:1:$gid \
--gidmap $(($gid+1)):$(($gid+1)):$(($subgidSize-$gid)) \
$container $args
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment