Skip to content

Latest commit

 

History

History
315 lines (222 loc) · 14.7 KB

01_Podman_Setup.md

File metadata and controls

315 lines (222 loc) · 14.7 KB

Podman Machine Setup

Podman runs on top of a Linux host, which means that on macOS and Windows a virtual machine is required (like for Docker). Mimicking the docker machine, podman can create fedora CoreOS vm's (rootless or rootfull) and provide a docker compatible API runtime.

Let's see how to manage podman machines.

# List Machines
podman machine ls
NAME        VM TYPE     CREATED     LAST UP     CPUS        MEMORY      DISK SIZE
podman machine init
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  1.3M…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  3.3M…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  6.2M…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  10.1…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  13.2…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  17.4…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  23.3…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  29.2…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  35.0…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  40.9…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  46.6…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  52.3…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  58.1…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  64.0…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  69.8…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  75.6…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  81.4…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  86.9…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  92.4…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  98.2…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  104.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  109.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  114.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  120.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  126.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  132.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  137.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  143.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  149.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  155.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  160.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  166.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  172.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  177.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  183.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  189.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  194.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  199.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  200.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  205.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  210.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  215.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  221.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  227.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  232.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  238.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  243.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  249.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  255.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  261.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  266.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  272.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  278.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  283.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  289.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  294.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  300.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  306.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  312.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  317.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  323.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  329.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  335.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  340.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  346.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  352.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  358.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  363.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  369.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  375.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  380.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  386.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  391.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  397.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  403.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  408.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  414.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  420.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  425.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  431.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  437.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  443.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  449.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  455.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  460.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  466.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  472.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  477.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  483.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  488.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  494.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  499.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  505.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  510.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  516.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  522.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  528.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  534.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  539.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  545.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  551.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  557.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  562.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  568.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  573.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  579.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz  585.…
Downloading VM image: fedora-coreos-36.20220703.2.1-qemu.aarch64.qcow2.xz: done
Extracting compressed file
Image resized.
Machine init complete
To start your machine run:

	podman machine start
# Start Machine

podman machine start
Starting machine "podman-machine-default"
Waiting for VM ...
Mounting volume... /Users/guillem.riera:/Users/guillem.riera
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/usr/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/usr/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/usr/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/usr/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/usr/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/usr/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

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: /var/run/docker.sock
Docker API clients default to this address. You do not need to set DOCKER_HOST.

Machine "podman-machine-default" started successfully
# List Machines
podman machine list
NAME                     VM TYPE     CREATED        LAST UP            CPUS        MEMORY      DISK SIZE
podman-machine-default*  qemu        4 minutes ago  Currently running  1           2.147GB     107.4GB
# Stop a machine

podman machine stop
Machine "podman-machine-default" stopped successfully
# Start a stopped machine
podman machine start
Starting machine "podman-machine-default"
Waiting for VM ...
Mounting volume... /Users/guillem.riera:/Users/guillem.riera
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/usr/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/usr/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/usr/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/usr/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/usr/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/usr/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

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: /var/run/docker.sock
Docker API clients default to this address. You do not need to set DOCKER_HOST.

Machine "podman-machine-default" started successfully
# Destroy an existing machine (1/2)

# Stop first

podman machine stop
Machine "podman-machine-default" stopped successfully
# Destroy an existing machine (2/2)

# Then delete

podman machine rm --force

Podman Custom Setup

It is possible to customize the machine's size (CPU, Memory, Disk and "Rootfulness").

For example, if we want to run a big number of containers or containers that need a lot of resources (like a full minikube container) we can add several flags to obtain a bigger podman machine:

podman machine init --cpus 2 --memory 8192 --rootful
Extracting compressed file
Image resized.
Machine init complete
To start your machine run:

	podman machine start
# List Machines
podman machine ls
NAME                    VM TYPE     CREATED        LAST UP        CPUS        MEMORY      DISK SIZE
podman-machine-default  qemu        2 minutes ago  2 minutes ago  2           8.59GB      107.4GB

Ensure proper functioning with QEMU 7 under macOS Apple Silicon M1 / M2 Processors

If you happen to have trouble with Apple Silicon processors chances are that a QEMU config generator made the wrong assumptions about the target CPU of the VM.

You can read this short article about it if you are interested in the details:

https://medium.com/@guillem.riera/podman-on-macos-m1-qemu-7-e9225ffa3453

Running this commands can solve this issue:

# Solving problems with Apple Silicon M1/M2 Processors and QEMU

# NOTE: Do not run this in Jupyter, use the terminal instead, or else you will get an error "sed: -I or -i may not be used with stdin"

# After $(podman init)
# Obtain the PODMAN_MACHINE name
# This will get the default one, set this value if you need another
export PODMAN_MACHINE=$(podman machine list -q --format '{{.Name}}')
sed -e 's/cortex-a57/host/g' -e 's/highmem=off/highmem=on/g' -i ""  $HOME/.config/containers/podman/machine/qemu/$PODMAN_MACHINE.json