Skip to content

Instantly share code, notes, and snippets.

@tnk4on
Last active October 19, 2023 18:28
Show Gist options
  • Save tnk4on/ce592b08bf89dfca26ac2d9c1f9085c4 to your computer and use it in GitHub Desktop.
Save tnk4on/ce592b08bf89dfca26ac2d9c1f9085c4 to your computer and use it in GitHub Desktop.

Podman machine os apply

Short ver.

% mkdir os-apply
% cd os-apply
% cat <<EOF > Containerfile
FROM quay.io/fedora/fedora-coreos:testing-devel
RUN touch /lib/test.txt \
&& ostree container commit
EOF
% podman build -t os-apply .
% podman push os-apply:latest quay.io/tnk4on/os-apply
% podman machine init test
% podman machine start test
% podman machine ssh test ls -ld /lib/test.txt
ls: cannot access '/lib/test.txt': No such file or directory
% podman machine os apply quay.io/tnk4on/os-apply test
% podman machine stop test
% podman machine start test
% podman machine ssh test ls -ld /lib/test.txt
-rw-r--r--. 1 root root 0 Oct 20 03:21 /lib/test.txt

Full log ver.

% mkdir os-apply
% cd os-apply
% cat <<EOF > Containerfile
FROM quay.io/fedora/fedora-coreos:testing-devel
RUN touch /lib/test.txt \
&& ostree container commit
EOF
% podman build -t os-apply .
STEP 1/2: FROM quay.io/fedora/fedora-coreos:testing-devel
STEP 2/2: RUN touch /lib/test.txt && ostree container commit
--> Using cache a44858bdfeb9539232cf39f38e115d0aae2444c1de27b71a1968d3c904046714
COMMIT os-apply
--> a44858bdfeb9
Successfully tagged localhost/os-apply:latest
a44858bdfeb9539232cf39f38e115d0aae2444c1de27b71a1968d3c904046714
% podman push os-apply:latest quay.io/tnk4on/os-apply
% podman machine init test
Downloading VM image: fedora-coreos-38.20231014.2.0-qemu.aarch64.qcow2.xz: done
Extracting compressed file: test_fedora-coreos-38.20231014.2.0-qemu.aarch64.qcow2: done
Image resized.
Machine init complete
To start your machine run:

	podman machine start test
% podman machine start test
Starting machine "test"
Waiting for VM ...
Mounting volume... /Users:/Users
Mounting volume... /private:/private
Mounting volume... /var/folders:/var/folders

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 test

API forwarding listening on: /var/run/docker.sock
Docker API clients default to this address. You do not need to set DOCKER_HOST.

Machine "test" started successfully
% podman machine ssh test ls -ld /lib/test.txt
ls: cannot access '/lib/test.txt': No such file or directory
% podman machine os apply quay.io/tnk4on/os-apply test
Pulling manifest: ostree-unverified-registry:quay.io/tnk4on/os-apply
Importing: ostree-unverified-registry:quay.io/tnk4on/os-apply (digest: sha256:04e0bf1c0e52c369d298b1fba99d3ae65f5bbf63cc572fd1ba34cc0d0d6c2ba1)
ostree chunk layers already present: 42
ostree chunk layers needed: 9 (214.8 MB)
custom layers needed: 1 (279 bytes)
Checking out tree 9d7f29c...done
Enabled rpm-md repositories: fedora-cisco-openh264 fedora-modular updates-modular updates fedora updates-archive
Updating metadata for 'fedora-cisco-openh264'...done
Updating metadata for 'fedora-modular'...done
Updating metadata for 'updates-modular'...done
Updating metadata for 'updates'...done
Updating metadata for 'fedora'...done
Updating metadata for 'updates-archive'...done
Importing rpm-md...done
rpm-md repo 'fedora-cisco-openh264'; generated: 2023-03-14T10:56:46Z solvables: 4
rpm-md repo 'fedora-modular'; generated: 2023-04-13T20:30:28Z solvables: 1068
rpm-md repo 'updates-modular'; generated: 2023-09-16T00:25:03Z solvables: 1082
rpm-md repo 'updates'; generated: 2023-10-19T01:06:00Z solvables: 22651
rpm-md repo 'fedora'; generated: 2023-04-13T20:36:48Z solvables: 59720
rpm-md repo 'updates-archive'; generated: 2023-10-17T02:20:06Z solvables: 42914
Resolving dependencies...done
Applying 1 override
Processing packages...done
Writing rpmdb...done
Writing OSTree commit...done
Staging deployment...done
Freed: 947.3 kB (pkgcache branches: 0)
Upgraded:
  kernel 6.5.6-200.fc38 -> 6.5.7-200.fc38
  kernel-core 6.5.6-200.fc38 -> 6.5.7-200.fc38
  kernel-modules 6.5.6-200.fc38 -> 6.5.7-200.fc38
  kernel-modules-core 6.5.6-200.fc38 -> 6.5.7-200.fc38
  libnghttp2 1.52.0-1.fc38 -> 1.52.0-2.fc38
Removed:
  moby-engine-20.10.23-1.fc38.aarch64
Changes queued for next boot. Run "systemctl reboot" to start a reboot
% podman machine stop test
Waiting for VM to exit...
Machine "test" stopped successfully
% podman machine start test
Starting machine "test"
Waiting for VM ...
Mounting volume... /Users:/Users
Mounting volume... /private:/private
Mounting volume... /var/folders:/var/folders

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 test

API forwarding listening on: /var/run/docker.sock
Docker API clients default to this address. You do not need to set DOCKER_HOST.

Machine "test" started successfully
% podman machine ssh test ls -ld /lib/test.txt
-rw-r--r--. 1 root root 0 Oct 20 03:21 /lib/test.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment