Chapter 5. Best practices for running containers using local sources
You can access content hosted in an internal registry that requires a custom Transport Layer Security (TLS) root certificate, when running RHEL bootc images.
There are two options available to install content to a container by using only local resources:
-
Bind mounts: Use for example
-v /etc/pki:/etc/pki
to override the container’s store with the host’s. -
Derived image: Create a new container image with your custom certificates by building it using a
Containerfile
.
You can use the same techniques to run a bootc-image-builder
container or a bootc
container when appropriate.
5.1. Importing custom certificate to a container by using bind mounts
Use bound mounts to override the container’s store with the host’s.
Procedure
Run bootc-image-builder and use a bind mount, for example
-v /etc/pki:/etc/pki
, to override the container’s store with the host’s:podman run \ --rm \ -it \ --privileged \ --pull=newer \ --security-opt label=type:unconfined_t \ -v $(pwd)/output:/output \ -v /etc/pki:/etc/pki \ registry.redhat.io/rhel10/bootc-image-builder:latest \ --type iso \ --config /config.toml \ quay.io/<namespace>/<image>:<tag>
# podman run \ --rm \ -it \ --privileged \ --pull=newer \ --security-opt label=type:unconfined_t \ -v $(pwd)/output:/output \ -v /etc/pki:/etc/pki \ registry.redhat.io/rhel10/bootc-image-builder:latest \ --type iso \ --config /config.toml \ quay.io/<namespace>/<image>:<tag>
Copy to Clipboard Copied!
Verification
- The disk image build process should now be able to access internal certificates.
5.2. Importing custom certificates to an image by using Containerfile
Include instructions to install custom certificate roots with a Containerfile
.
Procedure
Create a
Containerfile
:FROM <internal_repository>/<image> # Add certificate to the input set of anchors COPY additional-certificate-root.pem /etc/pki/ca-trust/source/anchors RUN update-ca-trust
FROM <internal_repository>/<image> # Add certificate to the input set of anchors COPY additional-certificate-root.pem /etc/pki/ca-trust/source/anchors RUN update-ca-trust
Copy to Clipboard Copied! Build the custom image:
podman build -t <your_image> .
# podman build -t <your_image> .
Copy to Clipboard Copied! Run the
<your_image>
:podman run -it --rm <your_image>
# podman run -it --rm <your_image>
Copy to Clipboard Copied!
Verification
Verify your certificate is in the generated merged store:
cat etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem ...
# cat etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem ...
Copy to Clipboard Copied!