Use Case - Simple RHEL bootc container
This example shows a very simple example of a bootc container the is built starting from a rhel-bootc image.
The Containerfile in the example:
- Updates packages
- Installs tmux and mkpasswd to create a simple user password
- Creates a bootc-user user in the image
- Adds the wheel group to sudoers
Review Containerfile.simple
MAINTAINER Alessandro Rossi <al.rossi87@gmail.com>
FROM registry.redhat.io/rhel9/rhel-bootc:9.5
RUN dnf -y update && dnf -y install tmux mkpasswd
RUN pass=$(mkpasswd --method=SHA-512 --rounds=4096 redhat) && useradd -m -G wheel bootc-user -p $pass
RUN echo "%wheel ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/wheel-sudo
Building the image
From the root folder of the repository, switch to the use case directory:
To build the image:
You can now run it using:
Note: The "-p 2022:22" part forwards the container's SSH port to the host 2022 port.
The container will now start and a login prompt will appear:
You can simply login with bootc-user/redhat and play around with the container content!