 Podman for Windows ================== While "containers are Linux," Podman also runs on Mac and Windows, where it provides a native CLI and embeds a guest Linux system to launch your containers. This guest is referred to as a Podman machine and is managed with the `podman machine` command. On Windows, each Podman machine is backed by a virtualized Windows Subsystem for Linux (WSLv2) distribution or an Hyper-V virtual machine. The Podman command can be run directly from your Windows PowerShell (or CMD) prompt, where it remotely communicates with the podman service running in the guest environment. In addition to command-line access, Podman also listens for Docker API clients, supporting direct usage of Docker-based tools and programmatic access from your language of choice. Table of Contents ------------------ - [Prerequisites](#prerequisites) - [Installing Podman](#installing-podman) - [Directories, files and registry keys used by Podman on Windows](#directories-files-and-registry-keys-used-by-podman-on-windows) - [Machine Init Process](#machine-init-process) - [Starting Machine](#starting-machine) - [First Podman Command](#first-podman-command) - [Port Forwarding](#port-forwarding) - [Using API Forwarding](#using-api-forwarding) - [Rootful & Rootless](#rootful--rootless) - [Configuring the Machine Provider](#configuring-the-machine-provider) - [Volume Mounting](#volume-mounting) - [Listing Podman Machine(s)](#listing-podman-machines) - [Accessing the Podman Linux Environment](#accessing-the-podman-linux-environment) - [Using SSH](#using-ssh) - [Using the WSL Command](#using-the-wsl-command) - [Using Windows Terminal Integration](#using-windows-terminal-integration) - [Stopping a Podman Machine](#stopping-a-podman-machine) - [Removing a Podman Machine](#removing-a-podman-machine) - [Uninstalling Podman](#uninstalling-podman) - [Troubleshooting](#troubleshooting) - [Installing WSL Manually](#installing-wsl-manually) - [Install Certificate Authority](#install-certificate-authority) Prerequisites ------------- Because Podman uses WSLv2 or Hyper-V recent features, you need Windows 11 or later. Internally, WSL and Hyper-V use virtualization, so your system must support and have hardware virtualization enabled. If you are running Windows on a VM, you must have a VM that supports nested virtualization. Hyper-V is only available on Windows Enterprise, Pro, or Education editions (not Home). The command to initialize the first Hyper-V Podman machine, and the command to remove the last one, both require administrator privileges. Other commands for machine management (start, stop, etc...) require that the current user is a member of the Hyper-V administrators group. It is also recommended to install the modern "Windows Terminal," which provides a superior user experience to the standard PowerShell and CMD prompts, as well as a WSL prompt, should you want it. You can install it by searching the Windows Store or by running the following `winget` command: `winget install Microsoft.WindowsTerminal` Installing Podman ----------------- Installing the Windows Podman client begins by downloading the Podman Windows installer. The Windows installer is built with each Podman release and can be downloaded from the official [GitHub release page](https://github.com/containers/podman/releases). Be sure to download a Podman 6.0 or later release for the capabilities discussed in this guide. The Windows installer is provided as an MSI package (e.g., `podman-installer-windows-arm64.msi`). The installer supports both user-scope and machine-scope installations: - **User scope (per-user)**: No administrator privileges required. Files are installed in the user's profile directory (`%LOCALAPPDATA%\Programs\Podman`), and the PATH is updated only for the current user. This is the default scope. - **Machine scope (per-machine)**: Requires administrator privileges. Files are installed in `%PROGRAMFILES%\Podman`, and the PATH is updated for all users. During installation, you can select the virtualization provider (WSL or Hyper-V) that Podman will use for machines. The installer will create a configuration file at `%APPDATA%\containers\containers.conf.d\99-podman-machine-provider.conf` (for user scope) or `%PROGRAMDATA%\containers\containers.conf.d\99-podman-machine-provider.conf` (for machine scope) with the selected provider.  Once installed, relaunch a new terminal. After this point, `podman.exe` will be present on your PATH, and you will be able to run the `podman machine init` command to create your first machine. **Note:** WSLv2 or Hyper-V must be installed before creating Podman machines. If WSL is not installed, you can install it manually by running `wsl --install` from an administrator PowerShell prompt. The Podman installer no longer automatically installs WSL. If the Hyper-V feature is not enabled, you can enable it by running `Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All` from an administrator PowerShell prompt. ### Directories, files and registry keys used by Podman on Windows The following tables list the directories, files and registry keys used by Podman on Windows. | Directory or file | Description | |------------------------------------------------------------------------------|--------------------------------------------| | `%LocalAppData%\Programs\Podman\` | Installation directory | | `%APPDATA%\containers\containers.conf.d\99-podman-machine-provider.conf` | Installer created configuration file | | `%APPDATA%\containers\containers.conf` | Client main configuration file | | `%APPDATA%\containers\podman-connections.json` | Client connections configuration file | | `%USERPROFILE%\.local\share\containers\podman\machine` | Machines data directory | | `%USERPROFILE%\.config\containers\podman\machine\` | Machines configuration directory | | `%USERPROFILE%\.local\share\containers\storage\podman\` | Containers and images storage layers | | `%ProgramFiles%\Podman\` | Machine-scope installation directory | | `%ProgramData%\containers\containers.conf.d\99-podman-machine-provider.conf` | Machine-scope installer created conf file | | `%ProgramData%\containers\containers.conf` | Machine-scope client configuration file | Table: Directories and files used by Podman on Windows | Key | Description | |------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------| | `HKCU:\SOFTWARE\Podman` | Installation directory path | | `HKLM:\SOFTWARE\Podman` | Machine-scope Installation directory path | | `HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization\GuestCommunicationServices` | Hyper-V socket registry entries (`{PORT_HEX}-FACB-11E6-BD58-64006A7986D3` pattern) | Table: Registry keys used by Podman on Windows Machine Init Process -------------------- The `podman machine init` command will pull a custom Fedora OCI image (Fedora CoreOS when using Hyper-V) as an OCI artifact from `quay.io/podman/machine-os`. The image is customized to run Podman. ```powershell PS C:\Users\User> podman machine init Looking up Podman Machine image at quay.io/podman/machine-os:6.0 to create VM Getting image source signatures Copying blob 24c97bc42489 done | Copying config 44136fa355 done | Writing manifest to image destination 24c97bc424897b38d15d0e229b7a27487a1f8ed8ec8c019ccf2bb18add970db5 Extracting compressed file: podman-machine-default-arm64: done Importing operating system into WSL (this may take a few minutes on a new WSL install)... The operation completed successfully. Configuring system... Machine init complete To start your machine run: podman machine start ``` You can also specify the virtualization provider when initializing a machine: ```powershell PS C:\Users\User> podman machine init --provider wsl ``` or ```powershell PS C:\Users\User> podman machine init --provider hyperv ``` **Note:** Hyper-V requires administrator privileges to initialize the first podman machine. Similarly it requires administrator privileges to remove the last machine. That's because these operation create and delete machine-scope registry keys, required to support the communication between the guest OS and the host. Other commands such as machine start and stop require that the current user is a member of the Hyper-V Administrator group. Starting Machine ---------------- After the machine init process completes, it can then be started and stopped as desired: ```powershell PS C:\Users\User> podman machine start Starting machine "podman-machine-default" This machine is currently configured in rootless mode. If your containers require root permissions (e.g. ports < 1024), or if you run into compatibility issues with non-podman clients, you can switch using the following command: podman machine set --rootful API forwarding listening on: npipe:////./pipe/docker_engine Docker API clients default to this address. You do not need to set DOCKER_HOST. Machine "podman-machine-default" started successfully ``` First Podman Command -------------------- From this point on, podman commands operate similarly to how they would on Linux. For a quick working example with a small image, you can run the Linux date command on PowerShell. ```powershell PS C:\Users\User> podman run ubi9-micro date Thu May 5 21:56:42 UTC 2022 ``` If you get this error instead: ``` Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM Error: unable to connect to Podman socket: Get "http://d/v5.7.1/libpod/_ping": ssh: rejected: connect failed (open failed) ``` try to restart the machine in rootful mode like this: ``` podman machine stop podman machine set --rootful podman machine start podman run ubi8-micro date ``` Port Forwarding --------------- Port forwarding also works as expected; ports will be bound against localhost (127.0.0.1). **Note:** When running as rootless (the default), you must use a port greater than 1023. See the Rootful and Rootless section for more details. To launch httpd, you can run: ```powershell PS C:\Users\User> podman run --rm -d -p 8080:80 --name httpd docker.io/library/httpd f708641300564a6caf90c145e64cd852e76f77f6a41699478bb83a162dceada9 ``` A curl command against localhost on the PowerShell prompt will return a successful HTTP response: ```powershell PS C:\Users\User> Invoke-WebRequest -UseBasicParsing http://localhost:8080/ StatusCode : 200 StatusDescription : OK Content :