Developers are always asking us about how to customize Podman machine to add or subtract content. Up until recently, the answer has always been to use the cosa tooling to create the operating system and a qcow image. The process is not particularly difficult but it does help to have fast disk I/O, fast network connections, and a bare-metal operating system with Podman installed.
But recent work by the OSTree developers has changed the game. OSTree now has the capability to rebase itself from the content of an OCI image. And better yet, the image can be built with a simple Containerfile using podman build. For Podman, it is a perfect match of technologies and will resolve a number of ongoing problems with Podman machine.
The most common request we get for customization is to have an image with the latest Podman. In the example section, I will provide the commands to consume the Fedora COPR Podman-Next repository which has the latest version of Podman from upstream.
Create a machine with more than default resources
$ podman machine init -m 4192 --cpus 4 --disk-size 30 –-now builder
Clone the coreos layering examples
$ git clone https://github.com/coreos/layering-examples
Build your new image with podman
$ cd layering-examples/podman-next $ podman build -t podman_next https://raw.githubusercontent.com/coreos/coreos-layering-examples/main/podman-next/Containerfile
SSH into the machine
$ podman machine ssh builder
Now that the image is built, you have two options for consuming the image. If you need to use the new image more than once or share it with others, it might be best to push the image to an image repository like quay.io as described in Option 1. Otherwise Option 2 allows you to perform everything locally and avoid the network use for pushing and re-pulling.
Option 1
$ podman tag localhost/podman_next quay.io/baude/podman_next
$ sudo rpm-ostree --bypass-driver --experimental rebase ostree-unverified-registry:quay.io/baude/podman_next
Option 2
$ skopeo copy containers-storage:localhost/podman_next oci:/var/tmp/podman_next
$ sudo rpm-ostree --bypass-driver --experimental rebase ostree-unverified-image:oci:/var/tmp/podman_next
You must now reboot the machine for changes to take place.
/
Leave a Reply