iTranslated by AI
Exploring Podman: A Rootless and Daemonless Container Tool
I was interested in what rootless and daemonless were like, so I tried out Podman.
Actually, Docker also has a rootless mode, which allows you to run containers with regular user privileges. However, the explanation seemed long, so I think I'll try that another time.
Rootless mode | Docker Docs
Podman is supposedly rootless and daemonless. There's no need to add yourself to a docker group or run it with sudo. Furthermore, the Podman CLI offers a user experience similar to the Docker CLI. The learning cost is low, and the hurdle for migrating from Docker seems small.
Why "Rootless" is Convenient
There are two reasons why I wanted to try out "rootless" tools this time.
- Convenience in development environments
- Security
Convenience in development environments
Normally, when I use devcontainers for development, I find the handling of file owners and groups to be inconvenient. It's necessary to match the UID and GID between the host and the container.
For example, if you work as the root user inside a container without thinking about it, the files created inside the container will be owned by the root user, making it impossible for a regular user on the host to edit or delete them.
Basically, while I develop on the container, I often want to touch files on the host as well, so this is inconvenient.
To avoid this problem, some techniques involve passing the UID and GID when building the image.
Besides that, devcontainer has an option called updateRemoteUserUID that mitigates this issue.
Dev Container metadata reference
Roughly speaking, this is an option that does the following:
- Changes the user and group IDs on the container to match the user and group IDs on the host.
- Executes
chmodwith the-Roption to change the owner of the user's home directory on the container.
However, it doesn't change anything outside of the home directory, so this alone doesn't solve everything.
Security
The danger of having root privileges on a host is well-known, but running applications as the root user inside a container can also be a security risk.
Of course, even for a root user, the resources visible from inside the container are limited; for example, files and processes are restricted to those within the container. However, the user itself is the same as the root user on the host.
$ mkdir container-exp && cd $_
# Let's try creating a file inside the container...
$ docker run -v .:/host -w /host ubuntu touch hello.txt
# The owner is the root user!
$ ls -l
total 0
-rw-r--r-- 1 root root 0 Jun 24 23:22 hello.txt
So, if a container escape occurs, someone could wreak havoc on the host.
This problem can be solved using a Linux feature called "user namespaces." This mechanism allows you to map users and groups on a container to different users and groups on the host.
Podman also uses this feature.
Trying out Podman
Now, let's try out Podman. On Ubuntu, you can install it with apt.
$ sudo apt install podman
Verifying that User Namespaces Work
Let's try doing what we did earlier with Podman. Just replace the docker command with the podman command.
$ podman run -v .:/host -w /host ubuntu touch hello-podman.txt
# The owner is now a regular user!
$ ls -l
total 0
-rw-r--r-- 1 musou1500 musou1500 0 Jun 24 23:24 hello-podman.txt
Using it with devcontainer
Here is the source code.
musou1500/try-podman
The Dockerfile looks like this.
FROM node:22-bookworm AS base
WORKDIR /app
RUN chown -R node:node /app
USER node
COPY package*.json ./
RUN npm i
COPY . .
CMD ["npm", "start"]
When you open it as a devcontainer, the owner of various files becomes the node user, and even when creating files within the container, the owner matches the user on the host.
Even if I change the Dockerfile to use the root user inside the container, the result is the same.
The user mapping method can be specified with the --userns option. The default is keep-id, where the container's UID/GID are mapped to the host's UID/GID.
keep-id: creates a user namespace where the current rootless user’s UID:GID are mapped to the same values in the container. This option is not allowed for containers created by the root user.
podman-run — Podman documentation
As a side note, for some reason, it didn't work when I tried it on WSL. Here are the logs.
[2025-06-24T16:18:36.908Z] Start: Starting container
[2025-06-24T16:18:36.908Z] Start: Run: podman run --sig-proxy=false -a STDOUT -a STDERR --mount source=/home/xxx/code/try-podman,target=/app,type=bind,consistency=cached --mount type=volume,src=vscode,dst=/vscode -l devcontainer.local_folder=\\wsl.localhost\Ubuntu\home\xxx\code\try-podman -l devcontainer.config_file=/home/xxx/code/try-podman/.devcontainer/devcontainer.json --security-opt label=disable --userns=keep-id --entrypoint /bin/sh vsc-try-podman-7ed9c4b341460b05072adecee7d0738cf4107d58a197097c14f2ab6d4eb2d877 -c echo Container started
[2025-06-24T16:18:43.088Z] Error: could not find slirp4netns, the network namespace can't be configured: exec: "slirp4netns": executable file not found in $PATH
I confirmed that slirp4netns is installed, so I think the cause lies elsewhere. When I removed the automatic tmux startup setting in my .zshrc, the error stopped appearing for some reason, but then I encountered an issue where the process wouldn't finish and got stuck. Looking at the logs, it stops at the point where podman run is executed.
[7349 ms] Start: Run: podman run --sig-proxy=false -a STDOUT -a STDERR --mount type=bind,source=/home/xxx/code/try-podman,target=/workspaces/try-podman --mount type=volume,src=vscode,dst=/vscode -l devcontainer.local_folder=\\wsl.localhost\Ubuntu\home\xxx\code\try-podman -l devcontainer.config_file=/home/xxx/code/try-podman/.devcontainer/devcontainer.json --security-opt label=disable --userns=keep-id --entrypoint /bin/sh vsc-try-podman-7ed9c4b341460b05072adecee7d0738cf4107d58a197097c14f2ab6d4eb2d877 -c echo Container started
Container started
Thoughts
Using Podman itself feels very good. I didn't encounter any issues during installation, and since the usage is almost identical to Docker, the barrier to migration is low. It also seemed to solve the file permission issues I was initially hoping for.
However, there's a sense that the ecosystem hasn't quite caught up yet, as seen with the issues in the WSL environment, and I hope this will be improved in the future. I considered investigating this further, but since the source code for the VS Code extension is not public, there wasn't much I could do.
With the trend toward standardizing container specifications and the development of various other tools, the Docker-dominated landscape seems to be changing. I'm looking forward to future developments.
Discussion