-
-
Notifications
You must be signed in to change notification settings - Fork 34
blog: Podman and Docker Rootless in DDEV, fixes #453 #476
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
base: main
Are you sure you want to change the base?
Conversation
|
🌐 Fork Preview for PR #476 https://pr-476.ddev-com-fork-previews.pages.dev This preview updates automatically when you push changes to your fork. |
4eb31c6 to
5dc0225
Compare
|
Just starting on this... Since this will come out before v1.25.0, it should mention the v1.25.0 or HEAD requirement to test, right? |
rfay
left a comment
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.
Here's my first visit. Congrats on this milestone.
As mentioned, this should probably discourage people from using these options unless they know they need them. Early on it should have a link to normal setup and say "You don't need this unless you think you want it :) "
Now I'll experiment with the various options.
| - **Removed legacy docker-compose features** ([#7642](https://github.com/ddev/ddev/pull/7642)): Podman refuses to work with deprecated `links` and `external_links` directives in `docker-compose` files. We removed these legacy features and modernized DDEV's compose file generation. | ||
| - **Added Podman and Docker Rootless support** ([#7702](https://github.com/ddev/ddev/pull/7702)): DDEV now detects and supports Podman (rootful and rootless) and Docker Rootless. We added handling for Podman-specific limitations and enabled rootless environments to work without root privileges. | ||
|
|
||
| These changes enabled Podman and Docker Rootless support. |
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.
An amazing journey, congratulations!
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.
Maybe add a small statement about why these two features go hand-in-hand, why they developed together.
| - Container processes cannot access root-owned files | ||
| - Reduced attack surface if a container is compromised | ||
|
|
||
| Podman is rootless by default. Docker Rootless requires special setup. |
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.
It is probably worth explaining here that DDEV's traditional support has had its containers run as an unprivileged user, limiting the attack space. DDEV's built-in containers do not use root privileges (although docker itself does need root by default)
|
|
||
| After installing Podman, enable the API socket so DDEV can connect. | ||
|
|
||
| ### Podman Rootless on Linux |
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.
Should this say "Linux and WSL2" ?
|
|
||
| ## Setting Up Docker Rootless with DDEV | ||
|
|
||
| Docker Rootless offers rootless security with full Docker compatibility. |
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.
This is linux-only right? Should mention that.
| - [Mounting a volume with rootless always assigns ownership to root](https://github.com/moby/moby/issues/45919) | ||
| - [Add ability to mount volume as user other than root](https://github.com/moby/moby/issues/2259) | ||
|
|
||
| The `root` user inside the container maps to your host user, but many services will not run as root: |
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.
It's interesting that this is the same classic problem we've had with Docker Desktop for Linux and for a time with virtiofs.
| ddev start | ||
| ``` | ||
|
|
||
| ## Which Runtime Should You Choose? |
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.
Great section. However, it should encourage standard Docker setup first, with link to the docs, as it's by far the best for local development.
rfay
left a comment
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.
Another comment: One reason people have often requested podman is the belief that it was the only open-source alternative to Docker Desktop. We should clear that up in here, pointing out the there are several other fully open source alternatives on every platform.
|
This and docs probably need a compatibility table showing all the options and what works etc. |
|
|
||
| ### Podman Installation Options | ||
|
|
||
| Podman can be installed with or without a GUI: |
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.
I think we probably need a little more than this. I missed both podman init and podman start. Maybe one of those collapsed sections with basic instructions on macOS and Linux? The majority of our users are macOS, but probably the majority of interested users are on Linux.
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.
I'll check the formatting options for Markdown here.
|
I'm not sure if you already have this in there, but the inability to bind to default ports 80/443 is a pretty significant liability for a web developer. |
|
Just tried installing rootless podman in a isolated WSL Ubuntu environment: I got a warning "Problem with your Docker provider: installed Podman version 4.9.3 is not supported, please update to version 5.0 or newer." But it seem Ubuntu old has older versions available(?) $ sudo nala search podman
...
podman 4.9.3+ds1-1ubuntu0.2 [Ubuntu/noble universe]
└── tool to manage containers and podsInstall Podman Desktop on windows got a "current" version though: ❯ podman -v
podman version 5.7.0 |
4dd642a to
ae5ec1b
Compare
Summary of Changes from Original Version
Content that was shortened or removed
Overall Impact
|
| ## macOS | ||
|
|
||
| macOS users can use Podman and Podman Desktop, but setup has its own challenges. Docker Rootless is not available on macOS. | ||
|
|
||
| ### Installing Podman | ||
|
|
||
| Install Podman using Homebrew: | ||
|
|
||
| ```bash | ||
| brew install podman | ||
| ``` | ||
|
|
||
| Or install [Podman Desktop](https://podman-desktop.io/docs/installation/macos-install) if you prefer a GUI. | ||
|
|
||
| For more information, see the [official Podman installation guide for macOS](https://podman.io/docs/installation#macos) and [Podman tutorials](https://github.com/containers/podman/tree/main/docs/tutorials#readme). | ||
|
|
||
| ### Installing Docker CLI | ||
|
|
||
| ```bash | ||
| brew install docker | ||
| ``` | ||
|
|
||
| ### Configuring Podman | ||
|
|
||
| After installing Podman, initialize and start the Podman machine: | ||
|
|
||
| ```bash | ||
| podman machine init | ||
| podman machine start | ||
| ``` | ||
|
|
||
| The Podman machine will automatically configure the socket. Verify it's running: | ||
|
|
||
| ```bash | ||
| podman info --format '{{.Host.RemoteSocket.Path}}' | ||
| ``` | ||
|
|
||
| If you have Docker CLI installed, you can create a context for Podman: | ||
|
|
||
| ```bash | ||
| # Create Podman context | ||
| docker context create podman-rootless \ | ||
| --description "Podman (rootless)" \ | ||
| --docker host="unix://$(podman info --format '{{.Host.RemoteSocket.Path}}')" | ||
|
|
||
| # Switch to the new context | ||
| docker context use podman-rootless | ||
|
|
||
| # Verify it works | ||
| docker ps | ||
| ``` | ||
|
|
||
| Otherwise, set the `DOCKER_HOST` environment variable in your shell profile (`~/.zshrc` or `~/.bashrc`): | ||
|
|
||
| ```bash | ||
| export DOCKER_HOST=unix://$(podman info --format '{{.Host.RemoteSocket.Path}}') | ||
| ``` |
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.
I didn't test macOS, hoping for possible improvements or tips from @rfay in this section.
bba5f65 to
ac6fe7e
Compare
rfay
left a comment
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.
I think this should either be targeted at the v1.25.0 release, or alternately promote it earlier and try to get some people to use HEAD.
It's looking good, I added some more suggestions.
Now I'll try some more manual testing.
|
|
||
| The DDEV community has requested Podman and Docker Rootless support for years. This support is now available in [DDEV HEAD](https://docs.ddev.com/en/stable/developers/building-contributing/#testing-latest-commits-on-head) as an experimental feature, general availability is planned for upcoming DDEV v1.25.0. | ||
|
|
||
| It allows DDEV to work in corporate environments where Docker Desktop is not allowed due to security policies or licensing restrictions. |
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.
| It allows DDEV to work in corporate environments where Docker Desktop is not allowed due to security policies or licensing restrictions. | |
| It allows DDEV to work in corporate environments where Podman or Rootless Docker are preferred due to security policies or licensing restrictions. |
| - Guides | ||
| --- | ||
|
|
||
| The DDEV community has requested Podman and Docker Rootless support for years. This support is now available in [DDEV HEAD](https://docs.ddev.com/en/stable/developers/building-contributing/#testing-latest-commits-on-head) as an experimental feature, general availability is planned for upcoming DDEV v1.25.0. |
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.
Add a TL;DR with simple statement/link about how to get going.
| - [Supporting DDEV Development](#supporting-ddevdevelopment) | ||
| - [Conclusion](#conclusion) | ||
|
|
||
| ## The Journey to Podman Support |
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.
I think this is great and useful, but should probably move to the bottom. It's too much for most people to absorb, and not directly relevant to getting them going.
|
|
||
| All of these work with DDEV. The main reason to choose Podman specifically is if your organization forbids Docker entirely or if you want rootless operation by default. | ||
|
|
||
| ### Why Choose Rootless? |
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.
Great section. Maybe "Why choose Podman" right after it. Or before it.
|
|
||
| ### Why Choose Rootless? | ||
|
|
||
| Running containers without root privileges is more secure. Traditional Docker and rootful Podman need elevated privileges, which creates security risks in corporate environments where strict security policies apply. |
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.
| Running containers without root privileges is more secure. Traditional Docker and rootful Podman need elevated privileges, which creates security risks in corporate environments where strict security policies apply. | |
| Although DDEV's use of all Docker providers is quite secure, and we run containers as normal users with limited privileges, the rootless approaches to Docker and Podman actually run the *docker daemon* without root privileges, closing additional attack surface. Traditional Docker and rootful Podman daemons need elevated privileges, which creates security risks in corporate environments where strict security policies apply. (Note that DDEV is targeted at local development, where there are few risks of specialized attacks using this vector anyway.) |
| docker ps | ||
| ``` | ||
|
|
||
| **Option B: Set environment variable in your shell profile** (`~/.bashrc` or `~/.zshrc`): |
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.
I guess I'd prefer not to mention DOCKER_HOST, but open to conversation. I think docker contexts are better to use.
|
|
||
| For additional details, see the [Podman socket activation documentation](https://github.com/containers/podman/blob/main/docs/tutorials/socket_activation.md). | ||
|
|
||
| ### Configuring Podman Rootful |
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.
I think you had said earlier that podman is innately rootless, so this may need some clarification? Probably we don't even need to cover podman rootful if it has no value.
|
|
||
| ### Podman Rootless Performance Optimization | ||
|
|
||
| Podman Rootless is slower than Docker. See these resources: |
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.
| Podman Rootless is slower than Docker. See these resources: | |
| Podman Rootless is significantly slower than Docker. See these resources: |
|
|
||
| ### Recommendations | ||
|
|
||
| **Use [standard Docker](https://docs.ddev.com/en/stable/users/install/docker-installation/) if:** |
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.
| **Use [standard Docker](https://docs.ddev.com/en/stable/users/install/docker-installation/) if:** | |
| **Use of the many [standard Docker providers](https://docs.ddev.com/en/stable/users/install/docker-installation/) if:** |
|
|
||
| - You're comfortable with the most widely used container runtime | ||
| - You don't have rootless security requirements | ||
| - This is the recommended option for most users |
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.
| - This is the recommended option for most users | |
| _This is the recommended option for the vast majority of users._ |
rfay
left a comment
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.
I got it working fine on macOS and will use it for a while for daily use.
I didn't succeed with Fedora 43. The /mnt/ddev_config was always mounted as root and couldn't be copied at startup time.
I imagine this was something I did wrong.
|
|
||
| ### Configuring Podman Rootless | ||
|
|
||
| This is the recommended configuration for most users. |
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.
Is there even a reason to explain podman rootful?
|
|
||
| This is the recommended configuration for most users. | ||
|
|
||
| 1. In order for users to run rootless Podman, a `subuid` and `subgid` configuration entry must exist for each user that wants to use it. New users created using `useradd` have these entries by default: |
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.
Can we make this a little smarter? Either check whether it exists already in the statement, or make it less obvious? Since it's the first step... everybody will do it, and end up with broken system like I did. I think username:1000:165535 is a great default, but if it has something more specific in there already... remove it? Respect it?
The Issue
How This PR Solves The Issue
Adds a blog.
I haven't tested any configuration with Podman Desktop yet, so I don't know if additional configuration is needed there.
Manual Testing Instructions
https://pr-476.ddev-com-fork-previews.pages.dev/blog/podman-and-docker-rootless/
Automated Testing Overview
Related Issue Link(s)
Release/Deployment Notes