bone.recipes



Podman notes

Volume permissions

I always forget this, but it's necessary to include :z (or :Z) at the end of volume options when running a container in Linux, like this:

podman run --rm -it -v /some/host/path:/some/guest/path:z some-image

Failing to include :z will result in "permission denied" errors inside the container.

Apparently, this issue is related to SELinux, about which I know absolutely nothing. See this article for more info on what's happening under the hood.

Sudo users

In a Dockerfile, a sudo user can be added like this (using actual values for $username and $password):

FROM: docker.io/ubuntu:latest
RUN apt-get update
RUN apt-get install -y sudo
RUN useradd -m $username
RUN echo "$username:$password" | chpasswd
RUN usermod -aG sudo $username
USER $username

# To run a command with `sudo`, use the `-S` option to read the password from `stdin`:
RUN echo "$password" | sudo -S whatever

Source: https://stackoverflow.com/a/25908200

Equivalent of source

Where you'd normally do:

source some/file

In a Dockerfile, do:

RUN . some/file