Ok I was struggling a bit finding info about this. In a nutshell:
/var/run/docker.sock
only works for root(ful) containers- there's no rootless socket-file created by default (you need to run an API listener service)
# whoami
root
# su -l john -c 'podman system service --time 0' &>/var/log/podman.john.log # move this to boot/init script e.g.
# chmod 660 $(podman info|grep 'podman.sock'| awk '{print $2}') # https://github.com/containers/podman/issues/6787
nice..now john's
podman.sock
is alive
here's a rootless a container which uses a socket-file to control podman (as john
):
$ whoami
john
$ cat start.sh
socket=/var/run/docker.sock
test $(whoami) = root || {
socket=$(podman info|grep 'podman.sock'| awk '{print $2}') # run 'podman info' to verify
chmod 660 $socket # otherwise container can still not access the socketfile
}
podman run --security-opt label=disable \ `# see https://docs.podman.io/en/latest/markdown/podman-system-service.1.html
-d -v $socket:/var/run/docker.sock \
-p 8000:8000 --name=yacht ghcr.io/selfhostedpro/yacht:latest
$ ./start.sh
634efa34ef6a4ef5a6e3fa563efa566665a6
$
``
> PROFIT!