Skip to content

fix(rust): add fallback to Podman sockets for docker_environments#23520

Open
thiago-carbonera wants to merge 2 commits into
pantsbuild:mainfrom
thiago-carbonera:fix-podman-socket
Open

fix(rust): add fallback to Podman sockets for docker_environments#23520
thiago-carbonera wants to merge 2 commits into
pantsbuild:mainfrom
thiago-carbonera:fix-podman-socket

Conversation

@thiago-carbonera

Copy link
Copy Markdown
Contributor

Fixes #22936.

Problem

Currently, users utilizing Podman for docker_environments face connection errors because the Rust engine (using the Bollard client) strictly defaults to the standard Docker socket (/var/run/docker.sock). When this socket is not found, the execution fails, forcing users to manually set the DOCKER_HOST environment variable to point to their Podman socket.

Solution

This PR introduces a fallback mechanism when initializing the Docker client in docker.rs:

  • It first attempts to connect using standard local defaults.
  • If that fails, it proactively checks for the existence of common Podman socket paths:
    Rootless Podman: $XDG_RUNTIME_DIR/podman/podman.sock
    Rootful Podman: /run/podman/podman.sock
  • If either socket exists, it establishes the connection using Docker::connect_with_socket.
  • If all attempts fail, it correctly bubbles up the original Docker connection error.

This eliminates the need for manual workarounds and provides out-of-the-box support for Podman users.

@sureshjoshi

Copy link
Copy Markdown
Member

Thanks for the PR, but I don't think this is the right approach.

A quick glance at the bollard changelogs shows that they seem to have been improving their Podman support. For example: fussybeaver/bollard#700

I think the fundamental issue is that our Bollard dep is 1.5 years old.

@tdyas tdyas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest version of bollard supports looking for podman sockets. Maybe just upgrade bollard to v0.21.0 which claims "first-class Podman support with feature flags" in the release notes?

@tdyas tdyas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does podman work with docker_environment if you just upgrade the bollard crate?

@thiago-carbonera

Copy link
Copy Markdown
Contributor Author

Hi @tdyas and @sureshjoshi! I just bumped the bollard workspace dependency to 0.21.0 locally to test this approach.
It turns out that upgrading from 0.18.1 to 0.21.0 brings a massive amount of API breaking changes from Bollard's side. Things like CreateContainerOptions and Config were heavily refactored, models were moved, and generics were dropped. This results in 30+ compilation errors across process_execution/docker/src/docker.rs.
Since fixing all of these requires a substantial refactor of the Docker engine code, how would you prefer to proceed?

@tdyas

tdyas commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

What version of bollard was the podman support added in? And how much "churn" is there in bollard for that version (versus upgrading all the way to 0.21.x)?

@thiago-carbonera

Copy link
Copy Markdown
Contributor Author

Hi @tdyas! I just checked the bollard release notes, and the 'first-class Podman support' was introduced exactly in version 0.21.0. Because it was only added in 0.21.0, there isn't an intermediate version we can upgrade to.
Let me know what i should do.

@tobni

tobni commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

#23552

I also think @thiago-carbonera you need to consider dialing back how much you allow an LLM to speak for you, if you are. If you're not I apologize in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Experimental Podman support does not work by default for docker_environments

4 participants