-
Notifications
You must be signed in to change notification settings - Fork 52
Add rootless podman image #339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Podman | ||
|
|
||
| [](https://hub.docker.com/r/codercom/enterprise-podman) | ||
|
|
||
| ## Description | ||
|
|
||
| Wraps [enterprise-base](../base/README.md) with rootless | ||
| [Podman](https://podman.io), so workspaces can build and run containers | ||
| without a privileged container runtime or custom RuntimeClass. `docker` is | ||
| aliased to `podman`. | ||
|
|
||
| This image was previously published as `ghcr.io/coder/podman` from the | ||
| now-archived | ||
| [community-templates](https://github.com/coder/community-templates/tree/main/kubernetes-podman) | ||
| repository. | ||
|
|
||
| ## How To Use | ||
|
|
||
| Visit | ||
| [Docker in Workspaces: Rootless Podman](https://coder.com/docs/admin/templates/extending-templates/docker-in-workspaces#rootless-podman) | ||
| for the template changes this image pairs with: an AppArmor `unconfined` | ||
| profile for the workspace container and a FUSE device exposed via | ||
| smarter-device-manager. | ||
|
|
||
| Rootless container storage lives under `~/.local/share/containers/storage`, | ||
| so it lands on the workspace home volume with no extra mounts required. | ||
|
|
||
| Nodes must have Linux user namespaces enabled | ||
| (`sysctl user.max_user_namespaces` greater than 0). Notably, | ||
| [Bottlerocket](https://github.com/bottlerocket-os/bottlerocket) disables them | ||
| by default, and EKS Auto Mode nodes cannot enable them at all. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| [containers] | ||
| netns="host" | ||
| userns="host" | ||
| ipcns="host" | ||
| utsns="host" | ||
| cgroupns="host" | ||
| cgroups="disabled" | ||
| log_driver = "k8s-file" | ||
| volumes = [ | ||
| "/proc:/proc", | ||
| ] | ||
| default_sysctls = [] | ||
| [engine] | ||
| cgroup_manager = "cgroupfs" | ||
| events_logger="file" | ||
| runtime="crun" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Storage configuration for rootless Podman inside a Kubernetes pod. | ||
| # See man 5 containers-storage.conf for all options. | ||
| # | ||
| # Note: runroot and graphroot below only apply when Podman runs as root. | ||
| # Rootless Podman (the expected mode for this image, running as the coder | ||
| # user) stores containers under ~/.local/share/containers/storage instead, | ||
| # so no extra volume mounts are required for those paths. | ||
|
|
||
| [storage] | ||
| # Default storage driver. fuse-overlayfs (set as the mount program below) | ||
| # lets the overlay driver work for unprivileged users. | ||
| driver = "overlay" | ||
|
|
||
| # Temporary storage location (rootful only; see note above) | ||
| runroot = "/run/containers/storage" | ||
|
|
||
| # Primary read/write location of container storage (rootful only; see note | ||
| # above) | ||
| graphroot = "/var/lib/containers/storage" | ||
|
Comment on lines
+15
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking question: From Coder Agents 🤖
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question — neither, actually: rootless Podman ignores (posted via Coder Agents on my behalf) |
||
|
|
||
| [storage.options] | ||
| # Read-only image stores shared into the image at build time. | ||
| additionalimagestores = [ | ||
| "/var/lib/shared", | ||
| ] | ||
|
|
||
| pull_options = {enable_partial_images = "false", use_hard_links = "false", ostree_repos=""} | ||
|
|
||
| [storage.options.overlay] | ||
| # Mount via fuse-overlayfs instead of mounting overlayfs directly, which | ||
| # unprivileged users cannot do. Pairs with a FUSE device exposed to the pod | ||
| # (e.g. via smarter-device-manager). | ||
| mount_program = "/usr/bin/fuse-overlayfs" | ||
|
|
||
| # Extra mount options | ||
| mountopt = "nodev,fsync=0" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| FROM codercom/enterprise-base:ubuntu | ||
|
|
||
| # Run everything as root | ||
| USER root | ||
|
|
||
| # Install Podman and rootless dependencies from Ubuntu's own repositories. | ||
| # uidmap provides newuidmap/newgidmap, which rootless Podman requires. | ||
| RUN apt-get update && \ | ||
| DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \ | ||
| podman \ | ||
| crun \ | ||
| fuse-overlayfs \ | ||
| slirp4netns \ | ||
| uidmap && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Allow the unprivileged coder user to map subordinate UID/GID ranges for | ||
| # rootless containers. | ||
| RUN setcap cap_setuid+ep /usr/bin/newuidmap && \ | ||
| setcap cap_setgid+ep /usr/bin/newgidmap && \ | ||
| chmod 0755 /usr/bin/newuidmap /usr/bin/newgidmap && \ | ||
| echo "coder:100000:65536" >/etc/subuid && \ | ||
| echo "coder:100000:65536" >/etc/subgid | ||
|
|
||
| COPY containers.conf /etc/containers/containers.conf | ||
| COPY storage.conf /etc/containers/storage.conf | ||
| RUN chmod 644 /etc/containers/containers.conf /etc/containers/storage.conf | ||
|
|
||
| # Read-only shared image stores referenced by storage.conf. | ||
| RUN mkdir -p /var/lib/shared/overlay-images \ | ||
| /var/lib/shared/overlay-layers \ | ||
| /var/lib/shared/vfs-images \ | ||
| /var/lib/shared/vfs-layers && \ | ||
| touch /var/lib/shared/overlay-images/images.lock \ | ||
| /var/lib/shared/overlay-layers/layers.lock \ | ||
| /var/lib/shared/vfs-images/images.lock \ | ||
| /var/lib/shared/vfs-layers/layers.lock | ||
|
|
||
| # Alias "docker" to "podman" | ||
| RUN [ -e /usr/bin/docker ] || ln -s /usr/bin/podman /usr/bin/docker | ||
|
|
||
| # Set back to coder user | ||
| USER coder |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,4 +36,5 @@ IMAGES=( | |
| "desktop" | ||
| "universal" | ||
| "kitchensink" | ||
| "podman" | ||
| ) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to the Podman image (Yarn keyring fix). It's correct and probably necessary now that
apt-keyis gone onresolute— but it's invisible in the PR title/body. Worth splitting into its own small PR (would unblockmainon its own) or at least calling it out in the description.From Coder Agents 🤖
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Called it out in the description instead of splitting — main is red either way and this unblocks it in one go.
(posted via Coder Agents on my behalf)