Link Search Menu Expand Document

Podman remote container host setup via Vagrant VirtualBox

Prerequisites:

Vagrant, VirtualBox, and Podman Windows Client can be installed from winget (Windows Package Manager Client) command line tool on Windows 10 & 11.

winget install --id Hashicorp.Vagrant

Winget install vagrant

winget install --id Oracle.VirtualBox

Winget install virtualbox

winget install --id RedHat.Podman

Winget install podman

Notes:

  1. You need to re-open command line window to be able to use Podman cli program
  2. You may need to reboot the computer for VirtualBox virtual network driver to take effect.

Setup:

  1. Git clone the main branch of the repository.
  2. Inside the git clone folder, run vagrant up to create the Vagrant environment in PowerShell, during vagrant up execution, you may see the following message: VirtualBox elevated privileges required
    Be sure to click the “Yes” button to grant the elevated privileges, the whole execution messages will be displayed like following: vagrant up using VirtualBox provider
  3. Generate an ed25519 SSH keypair files on Windows host, if you’ve never created before:
     ssh-keygen -t ed25519
    
  4. Copy the generated public key into the Vagrant Virtual Machine by following command in PowerShell:
     type $env:USERPROFILE\.ssh\id_ed25519.pub | vagrant ssh -c "cat >> ~/.ssh/authorized_keys"
    

    generate keypair and copy to VM

  5. Run vagrant ssh-config to get the SSH host binding port of the Vagrant VM: run vagrant ssh-config
  6. Run following command to get the remote socket path information of Podman in the Vagrant VM:

     vagrant ssh -c 'podman --remote info --format={{".Host.RemoteSocket.Path"}}'
    

    get podman socket path
    The above example shows the socket path is /tmp/podman-run-1000/podman/podman.sock.

  7. Run following command to add a remote VM connection settings on Host Windows machine, this example is using Port 2222, remote socket path is /tmp/podman-run-1000/podman/podman.sock, and the connection name is vg_podman:
     podman --remote system connection add vg_podman --identity $env:USERPROFILE\.ssh\id_ed25519 ssh://vagrant@127.0.0.1:2222/tmp/podman-run-1000/podman/podman.sock
    

    Then use podman system connection list to verify the connection setting.
    add remote connection

Additional notes

  1. After finish above steps, you can use podman info on Windows to verify remote container host connection status. run podman info Also you can run following commands to verify podman is functional, able to pull images from both Redhat Quay(quay.io) & Docker Hub(https://hub.docker.com) registry and able to create rootless containers and communicates in pod:
     podman pod create --name mypod
     podman run -dt --name banner_01 --pod mypod quay.io/libpod/banner
     podman run -it --rm --pod mypod docker.io/curlimages/curl http://localhost
    

    podman commands to run demo containers

  2. If you need to recreate the VM, Invoke vagrant destroy -f in the git clone folder, then vagrant up again. Only needs do above step 4. to copy the ed25519 public key from Windows into new VM.
  3. The VM will automatically suspend when Windows system shutdown or reboot, it’s state can be known via invoke vagrant status in the git clone folder, you need to resume the VM by running vagrant up to be able to use Podman host again. run vagrant status
  4. The podman daemon inside VM is using the “rootless” mode , which means it cannot binding to port less than 1024 when invoke podman run command.
  5. Due to the limitation of the NAT virtual network card of VirtualBox, if you want to access the running containers that has custom binding port, you need to reach it by 2nd network card of VM, which is Host-Only mode and the IP address can be found by following command:
     vagrant ssh -c 'ip addr show eth1'
    

    run vagrant ssh -c to find IP address of 2nd NIC

  6. If your Windows Host enable the Hyper-V or WSL 2 afterward, due to the underlying Hypervisor changed in Windows OS, you may experience the following error when vagrant up an already provisioned VM: vagrant up error You need to recreate the VM that described in notes 2.