Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 30, 2025

Add Podman Support to Azure Developer CLI

This PR adds support for Podman as an alternative container runtime in Azure Developer CLI, addressing the issue where users without Docker but with Podman installed were unable to use azd's container functionality.

Changes Summary

  • Implemented automatic container runtime detection (Docker → Podman fallback)
  • Added AZD_CONTAINER_RUNTIME environment variable for explicit runtime selection
  • Added Podman version detection and validation (requires Podman 3.0+)
  • Updated all container commands to use detected runtime
  • Added comprehensive test coverage for Podman scenarios
  • Updated error messages to mention both Docker and Podman
  • All code passes linting and spell checks
  • All existing tests continue to pass
  • Addressed code review feedback

Key Features

  1. Automatic Detection: azd tries Docker first, then falls back to Podman automatically
  2. Environment Variable: Set AZD_CONTAINER_RUNTIME=podman or =docker for explicit control
  3. No Breaking Changes: Existing Docker users experience no changes
  4. Version Requirements: Docker 17.09+ or Podman 3.0+
  5. Cross-Platform: Works on all platforms where Podman is supported

Usage Examples

# Automatic detection (recommended)
azd provision

# Explicit Podman selection
export AZD_CONTAINER_RUNTIME=podman
azd provision

# Explicit Docker selection
export AZD_CONTAINER_RUNTIME=docker
azd provision

Testing

  • Added 4 new test suites with 15+ test cases
  • All existing Docker tests continue to pass
  • Tests verify: version parsing (including pre-release/build metadata), automatic detection, explicit override, neither runtime available
  • Code quality: passes golangci-lint and cspell

Files Modified

  • cli/azd/pkg/tools/docker/docker.go (+120, -18 lines)
  • cli/azd/pkg/tools/docker/docker_test.go (+215 lines)
Original prompt

This section details on the original issue you should resolve

<issue_title>Azd Provision should support Podman when Docker is not installed</issue_title>
<issue_description>azd version 1.11.0 (commit 5b92e06)

Describe the bug
When I run 'azd provision', I get an error telling me that required external tools need to be installed. It says that docker is not installed although I have podman installed and $DOCKER_HOST set to podman. I also tried alias docker=podman.

To Reproduce
On a machine without docker but with podman, run 'azd provision'

Expected behavior
The azd tools should not naively expect everybody to install docker. A large portion of the developer community only use Podman or some other container runtime. The tools should be able to detect podman or other runtimes when checking for docker.

Environment
Information on your environment:
* Ubuntu 22.04

Additional context
Looking at the azd code, there are lots of places where checks are made to see if the required external tools are installed. In cli/azd/pkg/tools/docker/docker.go, the following function exists

func (d *Cli) CheckInstalled(ctx context.Context) error {
    toolName := d.Name()
    err := tools.ToolInPath("docker")
    if err != nil {
        return err
    }
    dockerRes, err := tools.ExecuteCommand(ctx, d.commandRunner, "docker", "--version")
    if err != nil {
        return fmt.Errorf("checking %s version: %w", toolName, err)
    }
    log.Printf("docker version: %s", dockerRes)
    supported, err := isSupportedDockerVersion(dockerRes)
    if err != nil {
        return err
    }
    if !supported {
        return &tools.ErrSemver{ToolName: toolName, VersionInfo: d.versionInfo()}
    }
    // Check if docker daemon is running
    if _, err := tools.ExecuteCommand(ctx, d.commandRunner, "docker", "ps"); err != nil {
        return fmt.Errorf("the %s daemon is not running, please start the %s service: %w", toolName, toolName, err)
    }
    return nil
}
```</issue_description>

<agent_instructions>consider the support for Podman, create a ENV as suggested by the user in the issue as the alternative runtime for containers. Enable checks for all OS'es as we do for Docker. Practice DRY principals and write as little code as possible and be sure to have proper test coverage as well.</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@ellismg</author><body>
Supporting `podman` in addition to `docker` is something we'd like to do.  We do probe for `docker` today (and we don't take shell aliases into account) but if there's some easy way for us to support `podman` we'd like to do it, I suspect the limited docker commands we run today could also work with `podman`.</body></comment_new>
<comment_new><author>@spboyer</author><body>
Podman currently has 1st class support in [Container Tools for VS Code](https://www.linkedin.com/pulse/vs-code-container-tools-210-out-now-matt-hernandez-j6y0c/), [Visual Studio (thru Container Tools)](https://developer.microsoft.com/blog/visual-studio-2026-insiders-using-podman-for-container-development) and also [Aspire](https://learn.microsoft.com/en-us/dotnet/aspire/fundamentals/setup-tooling?tabs=linux&pivots=dotnet-cli#container-runtime). We should definitely make this support change. 

@vhvb1989 @wbreza @rajeshkamal5050 </body></comment_new>
</comments>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@spboyer
Copy link
Member

spboyer commented Dec 30, 2025

@copilot - the local ENV should be related to the local container runtime, not AZURE, consider better naming perhaps AZD_CONTAINER_RUNTIME

"Add environment variable AZURE_CONTAINER_RUNTIME to specify alternative runtime"

- Add support for Podman as an alternative container runtime
- Implement automatic fallback from Docker to Podman
- Add AZURE_CONTAINER_RUNTIME environment variable for explicit runtime selection
- Update version checking to support Podman version format
- Add comprehensive tests for Podman support
- Update error messages to mention both Docker and Podman

Co-authored-by: spboyer <7681382+spboyer@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix azd provision to support Podman when Docker is not installed Add Podman support as fallback container runtime Dec 30, 2025
Copilot AI requested a review from spboyer December 30, 2025 15:37
Changed from AZURE_CONTAINER_RUNTIME to AZD_CONTAINER_RUNTIME to better
reflect that this is a local azd tool configuration, not an Azure service
configuration.

Co-authored-by: spboyer <7681382+spboyer@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 30, 2025

@copilot - the local ENV should be related to the local container runtime, not AZURE, consider better naming perhaps AZD_CONTAINER_RUNTIME

...

Renamed the environment variable from AZURE_CONTAINER_RUNTIME to AZD_CONTAINER_RUNTIME in commit fb0a5e6. The variable name now correctly reflects that this is a local azd tool configuration rather than an Azure service setting.

@spboyer spboyer marked this pull request as ready for review December 31, 2025 14:15
Copilot AI review requested due to automatic review settings December 31, 2025 14:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Podman support as a fallback container runtime for Azure Developer CLI, enabling users who have Podman installed but not Docker to use azd's container operations seamlessly.

Key Changes:

  • Automatic runtime detection with Docker-first fallback to Podman
  • Environment variable AZD_CONTAINER_RUNTIME for explicit runtime selection
  • Version validation for Podman (requires ≥3.0 for Docker CLI compatibility)

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
cli/azd/pkg/tools/docker/docker.go Adds Podman detection logic, version validation, and routes all container commands through detected runtime
cli/azd/pkg/tools/docker/docker_test.go Adds comprehensive tests for Podman version parsing, runtime detection, and environment variable override behavior

@spboyer
Copy link
Member

spboyer commented Dec 31, 2025

@copilot apply changes based on the comments in this thread

- Make versionInfo runtime-aware with separate podmanVersionInfo()
- Simplify error messages for service not running (consistent format)
- Use t.Setenv() instead of os.Setenv/defer for test isolation
- Update regex pattern to use \S+ for better clarity
- Add test coverage for Podman versions with pre-release/build metadata
- Add test for when neither Docker nor Podman is available
- Keep getContainerEngine() backward compatible (defaults to docker)

Co-authored-by: spboyer <7681382+spboyer@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 31, 2025

@copilot apply changes based on the comments in this thread

Applied all review feedback in commit 46852b1:

  1. Consistent error messages: Simplified service-not-running errors to use uniform format
  2. Runtime-aware version info: Added separate podmanVersionInfo() method with correct minimum version (3.0)
  3. Test isolation: Replaced os.Setenv/defer with t.Setenv() for proper test cleanup
  4. Improved regex: Changed pattern from [^\s]+ to \S+ for clarity
  5. Extended test coverage: Added tests for Podman pre-release/build versions and neither-runtime-available scenario
  6. Backward compatibility: Kept getContainerEngine() defaulting to "docker" to avoid breaking existing tests

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.

Azd Provision should support Podman when Docker is not installed

2 participants