Work with Builds
Managing Builds
Abstract
Chapter 1. Creating container images Copy linkLink copied to clipboard!
As an application developer, create container images using buildah, source-to-image, or the buildpacks strategy, depending on your source code, framework, and automation requirements. You can also use Open Container Initiative (OCI) artifacts to build container images.
1.1. Creating a buildah build Copy linkLink copied to clipboard!
Use a buildah build strategy to build and push a container image using a Dockerfile.
Prerequisites
- You have installed the Builds for Red Hat OpenShift Operator on the OpenShift Container Platform cluster.
-
You have installed the
ocCLI. -
Optional: You have installed the
shpCLI.
Procedure
Create a
Buildresource and apply it to the OpenShift Container Platform cluster. You can do so by using theoccommand or theshpcommand:Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
source- Defines the location where the source code is placed.
strategy- Defines the build strategy that you use to build the container.
paramValues-
Defines the parameter defined in the build strategy. To set the value of the
dockerfilestrategy parameter, specify the Dockerfile location required to build the output image. output-
Defines the location where the built image is pushed. In this procedural example, the built image is pushed to the OpenShift Container Platform cluster internal registry.
buildah-exampleis the name of the current project. Ensure that the specified project exists to allow the image push.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
source-context-dir- Defines the location where the source code is placed.
strategy-name- Defines the build strategy that you use to build the container.
dockerfile-
Defines the parameter defined in the build strategy. To set the value of the
dockerfilestrategy parameter, specifies the Dockerfile location required to build the output image. output-image-
Defines the location where the built image is pushed. In this procedural example, the built image is pushed to the OpenShift Container Platform cluster internal registry.
buildah-exampleis the name of the current project. Ensure that the specified project exists to allow the image push.
Check if the
Buildresource is created. You can do so by using theoccommand or theshpcommand:oc get builds.shipwright.io buildah-golang-build
$ oc get builds.shipwright.io buildah-golang-buildCopy to Clipboard Copied! Toggle word wrap Toggle overflow shp build list
$ shp build listCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
BuildRunresource and apply it to the OpenShift Container Platform cluster. You can do so by using theoccommand or theshpcommand:Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
spec.build.name- Defines the build to run, which is expected to be available in the same namespace.
shp build run buildah-golang-build --follow
$ shp build run buildah-golang-build --followCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
--follow:: (Optional) Use the--followflag to view the build logs in the output result.
Check if the
BuildRunresource is created. You can do so by using theoccommand or theshpcommand:oc get buildrun buildah-golang-buildrun
$ oc get buildrun buildah-golang-buildrunCopy to Clipboard Copied! Toggle word wrap Toggle overflow shp buildrun list
$ shp buildrun listCopy to Clipboard Copied! Toggle word wrap Toggle overflow The
BuildRunresource creates aTaskRunresource, which then creates the pods to execute build strategy steps.
Verification
After all the containers complete their tasks, verify the following resources:
Check whether the pod shows the
STATUSfield asCompleted:oc get pods -w
$ oc get pods -wCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
NAME READY STATUS RESTARTS AGE buildah-golang-buildrun-dtrg2-pod 2/2 Running 0 4s buildah-golang-buildrun-dtrg2-pod 1/2 NotReady 0 7s buildah-golang-buildrun-dtrg2-pod 0/2 Completed 0 55s
NAME READY STATUS RESTARTS AGE buildah-golang-buildrun-dtrg2-pod 2/2 Running 0 4s buildah-golang-buildrun-dtrg2-pod 1/2 NotReady 0 7s buildah-golang-buildrun-dtrg2-pod 0/2 Completed 0 55sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check whether the respective
TaskRunresource shows theSUCCEEDEDfield asTrue:oc get tr
$ oc get trCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME buildah-golang-buildrun-dtrg2 True Succeeded 11m 8m51s
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME buildah-golang-buildrun-dtrg2 True Succeeded 11m 8m51sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check whether the respective
BuildRunresource shows theSUCCEEDEDfield asTrue:oc get br
$ oc get brCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME buildah-golang-buildrun True Succeeded 13m 11m
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME buildah-golang-buildrun True Succeeded 13m 11mCopy to Clipboard Copied! Toggle word wrap Toggle overflow During verification, if a build run fails, you can check the
status.failureDetailsfield in yourBuildRunresource to identify the exact point where the failure happened in the pod or container.NoteThe pod might switch to a
NotReadystate because one of the containers has completed its task. This is an expected behavior.Validate whether the image has been pushed to the registry that is specified in the
build.spec.output.imagefield. Run the following command to pull the image from a node that can access the internal registry:podman manifest inspect image-registry.openshift-image-registry.svc:5000/buildah-example/taxi-app
$ podman manifest inspect image-registry.openshift-image-registry.svc:5000/buildah-example/taxi-appCopy to Clipboard Copied! Toggle word wrap Toggle overflow In the previous example, the project name is
buildah-example, and the image name istaxi-app.Example output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.2. Creating a source-to-image build Copy linkLink copied to clipboard!
Use a source-to-image(S2I) build strategy to turn application source code into a container image using a base image.
Prerequisites
- You have installed the Builds for Red Hat OpenShift Operator on the OpenShift Container Platform cluster.
-
You have installed the
ocCLI. -
Optional: You have installed the
shpCLI.
Procedure
Create a
Buildresource and apply it to the OpenShift Container Platform cluster. You can do so by using theoccommand or theshpcommand:Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
source- Defines the location where the source code is placed.
strategy- Defines the build strategy that you use to build the container.
paramValues-
Defines the parameter defined in the build strategy. To set the value of the
dockerfilestrategy parameter, specify the Dockerfile location required to build the output image. output-
Defines the location where the built image is pushed. In this procedural example, the built image is pushed to the OpenShift Container Platform cluster internal registry.
buildah-exampleis the name of the current project. Ensure that the specified project exists to allow the image push. pushSecret-
Defines the secret name that stores the credentials for pushing container images. To generate a secret of the type
docker-registryfor authentication, see "Authentication to container registries".
Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
source-context-dir- Defines the location where the source code is placed.
strategy-name- The build strategy that you use to build the container.
dockerfile-
The parameter defined in the build strategy. To set the value of the
dockerfilestrategy parameter, specify the Dockerfile location required to build the output image. output-image-
The location where the built image is pushed. In this procedural example, the built image is pushed to the OpenShift Container Platform cluster internal registry.
buildah-exampleis the name of the current project. Ensure that the specified project exists to allow the image push. output-credentials-secret-
The secret name that stores the credentials for pushing container images. To generate a secret of the type
docker-registryfor authentication, see "Authentication to container registries".
Check if the
Buildresource is created. You can do so by using theoccommand or theshpcommand:oc get builds.shipwright.io s2i-nodejs-build
$ oc get builds.shipwright.io s2i-nodejs-buildCopy to Clipboard Copied! Toggle word wrap Toggle overflow shp build list
$ shp build listCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
BuildRunresource and apply it to the OpenShift Container Platform cluster. You can do so by using theoccommand or theshpcommand:Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
spec.build.name- Specifies the respective build to run, which is expected to be available in the same namespace.
shp build run s2i-nodejs-build --follow
$ shp build run s2i-nodejs-build --followCopy to Clipboard Copied! Toggle word wrap Toggle overflow + where:
--follow-
(Optional) Use the
--followflag to view the build logs in the output result.
Check if the
BuildRunresource is created. You can do so by using theoccommand or theshpcommand:oc get buildrun s2i-nodejs-buildrun
$ oc get buildrun s2i-nodejs-buildrunCopy to Clipboard Copied! Toggle word wrap Toggle overflow shp buildrun list
$ shp buildrun listCopy to Clipboard Copied! Toggle word wrap Toggle overflow The
BuildRunresource creates aTaskRunresource, which then creates the pods to execute build strategy steps.
Verification
After all the containers complete their tasks, verify the statuses of the following resources:
Check whether the pod shows the
STATUSfield asCompleted:oc get pods -w
$ oc get pods -wCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
NAME READY STATUS RESTARTS AGE s2i-nodejs-buildrun-phxxm-pod 2/2 Running 0 10s s2i-nodejs-buildrun-phxxm-pod 1/2 NotReady 0 14s s2i-nodejs-buildrun-phxxm-pod 0/2 Completed 0 2m
NAME READY STATUS RESTARTS AGE s2i-nodejs-buildrun-phxxm-pod 2/2 Running 0 10s s2i-nodejs-buildrun-phxxm-pod 1/2 NotReady 0 14s s2i-nodejs-buildrun-phxxm-pod 0/2 Completed 0 2mCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check whether the respective
TaskRunresource shows theSUCCEEDEDfield asTrue:oc get tr
$ oc get trCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME s2i-nodejs-buildrun-phxxm True Succeeded 2m39s 13s
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME s2i-nodejs-buildrun-phxxm True Succeeded 2m39s 13sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check whether the respective
BuildRunresource shows theSUCCEEDEDfield asTrue:oc get br
$ oc get brCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME s2i-nodejs-buildrun True Succeeded 2m41s 15s
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME s2i-nodejs-buildrun True Succeeded 2m41s 15sCopy to Clipboard Copied! Toggle word wrap Toggle overflow During verification, if a build run fails, you can check the
status.failureDetailsfield in yourBuildRunresource to identify the exact point where the failure happened in the pod or container.NoteThe pod might switch to a
NotReadystate because one of the containers has completed its task. This is an expected behavior.Validate whether the image has been pushed to the registry that is specified in the
build.spec.output.imagefield. Log in to the registry and run the following command to pull the image:podman manifest inspect image-registry.openshift-image-registry.svc:5000/s2i-example/taxi-app
$ podman manifest inspect image-registry.openshift-image-registry.svc:5000/s2i-example/taxi-appCopy to Clipboard Copied! Toggle word wrap Toggle overflow In the previous example, the project name is
s2i-example, and the image name istaxi-app.Example output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.3. Creating a buildpacks build Copy linkLink copied to clipboard!
Use a buildpacks build to create and push container images to the target registry. The buildpacks cluster build strategy supports buildpacks and buildpacks-extender strategies.
Builds for Red Hat OpenShift supports the execution process for Cloud Native Buildpacks (CNB) within the build strategies. Red Hat does not provide support for the content of user-provided builder and runtime images. For more information on Cloud Native Buildpacks (CNB), see Cloud Native Buildpacks.
The buildpacks build strategy is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.
For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.
Prerequisites
- You have installed the Builds for Red Hat OpenShift Operator on the OpenShift Container Platform cluster.
-
You have installed the
ocCLI. -
You have created the project where your final application image is stored by using the command
oc new-project buildpacks-example. -
Optional: You have installed the
shpCLI.
Using shp CLI with buildpacks requires additional permissions setup that you must complete before you start creating a buildpacks build.
Procedure
Optional: Run the following commands to use the
shpCLI withbuildpacksand grant thepipelineservice account permission to access the image registry in thebuildpacks-exampleproject.oc policy add-role-to-user system:image-puller system:serviceaccount:default:pipeline --namespace=buildpacks-example
$ oc policy add-role-to-user system:image-puller system:serviceaccount:default:pipeline --namespace=buildpacks-exampleCopy to Clipboard Copied! Toggle word wrap Toggle overflow oc policy add-role-to-user system:image-pusher system:serviceaccount:default:pipeline --namespace=buildpacks-example
$ oc policy add-role-to-user system:image-pusher system:serviceaccount:default:pipeline --namespace=buildpacks-exampleCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Continue with
shpCLI by switching back to the primary working project:oc project default
$ oc project defaultCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Run the following command to apply the permission and finish
shpCLI setup:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
Buildresource and apply it to the OpenShift Container Platform cluster. You can do so by using theoccommand or theshpcommand:Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
source- Specifies the Git repository containing your application source code.
strategy- Specifies the build strategy to build the container.
paramValues- Specifies the parameters set for the buildpacks strategy.
name: run-image- Specifies the base image on which your application runs.
name: cnb-builder-image- Specifies the builder image used by Cloud Native Buildpacks (CNB) to detect and build your application.
name: source-subpath- Specifies the subdirectory within your Git repository where the application source code is located.
output- Specifies the location where the built image is pushed.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check if the
Buildresource is created. You can do so by using theoccommand or theshpcommand:oc get builds.shipwright.io buildpack-nodejs-build
$ oc get builds.shipwright.io buildpack-nodejs-buildCopy to Clipboard Copied! Toggle word wrap Toggle overflow shp build list
$ shp build listCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
BuildRunresource and apply it to the OpenShift Container Platform cluster. You can do so by using theoccommand or theshpcommand:Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
spec.build.nameSpecifies the
buildpack-nodejs-buildresource that will be executed.shp build run buildpack-nodejs-buildrun --follow
$ shp build run buildpack-nodejs-buildrun --followCopy to Clipboard Copied! Toggle word wrap Toggle overflow
ImportantThe
shpCLI version 0.16.0 cannot automatically generate a name for theBuildRunresource. You must create the name manually:Create a
BuildRunresource with a unique nameshp buildrun create buildpack-nodejs-<buildrun_resource_name> --buildref-name buildpack-nodejs-build
$ shp buildrun create buildpack-nodejs-<buildrun_resource_name> --buildref-name buildpack-nodejs-buildCopy to Clipboard Copied! Toggle word wrap Toggle overflow where:
<buildrun_resource_name>- Specifies the buildrun resource name
--buildref-name buildpack-nodejs-build- Defines the flag referencing the build.
Follow the logs:
shp buildrun logs buildpack-nodej-<buildrun_resource_name> --follow
$ shp buildrun logs buildpack-nodej-<buildrun_resource_name> --followCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Check if the
BuildRunresource is created. You can do so by using theoccommand or theshpcommand:oc get buildrun buildpack-nodejs-buildrun
$ oc get buildrun buildpack-nodejs-buildrunCopy to Clipboard Copied! Toggle word wrap Toggle overflow shp buildrun list
$ shp buildrun listCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe
BuildRunresource creates aTaskRunresource, which then creates the pods to execute build strategy steps.
Verification
- Wait for all containers to complete their tasks.
Check if the pod shows the
STATUSfield asCompleted:oc get pods -w
$ oc get pods -wCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
NAME READY STATUS RESTARTS AGE buildpack-go-build-ttwkl-d8x97-pod 2/8 NotReady 0 63s buildpack-go-build-ttwkl-d8x97-pod 0/8 Completed 0 72s buildpack-go-build-ttwkl-d8x97-pod 0/8 Completed 0 73s
NAME READY STATUS RESTARTS AGE buildpack-go-build-ttwkl-d8x97-pod 2/8 NotReady 0 63s buildpack-go-build-ttwkl-d8x97-pod 0/8 Completed 0 72s buildpack-go-build-ttwkl-d8x97-pod 0/8 Completed 0 73sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check if the
TaskRunresource shows theSUCCESSfield asTrue:oc get tr
$ oc get trCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME buildpack-go-build-ttwkl-d8x97 True Succeeded 112s 38s
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME buildpack-go-build-ttwkl-d8x97 True Succeeded 112s 38sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check if the
BuildRunresource shows theSUCCESSfield asTrue:oc get br
$ oc get brCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME buildpack-go-build-ttwkl True Succeeded 107s 33s
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME buildpack-go-build-ttwkl True Succeeded 107s 33sCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf the build run fails, you can check the
status.failureDetailsfield in yourBuildRunresource to identify the exact point where the failure happened in the pod or container.The pod might switch to a
NotReadystate because one of the containers has completed its task. This is an expected behavior.Run the following command from a node that can access internal registry to pull the image to check if the image has been pushed to the registry you specified in the
build.spec.output.imagefield:podman manifest inspect image-registry.openshift-image-registry.svc:5000/buildpacks-example/taxi-app
$ podman manifest inspect image-registry.openshift-image-registry.svc:5000/buildpacks-example/taxi-appCopy to Clipboard Copied! Toggle word wrap Toggle overflow In the previous example, the project name is
buildpacks-example, and the image name istaxi-app.Example output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.4. Creating a build with OCI artifacts Copy linkLink copied to clipboard!
Use Open Container Initiative (OCI) artifacts, also called scratch images, that you store in a registry as source code to build a container image. Pull and extract them to use as the source for your build; they contain only source code, not a runnable container.
Prerequisites
- You have installed the Builds for Red Hat OpenShift Operator on the OpenShift Container Platform cluster.
-
You have installed the
occommand-line interface (CLI). -
You have installed the
shpCLI.
Procedure
Create a
Buildresource and apply it to the OpenShift Container Platform cluster. See the following example configuration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
<build_resource_name>-
Specifies the name of the
Buildresource. <quay.io/org/image:tag>- Specifies the location of the OCI artifact source image.
<strategy_name>- Specifies the name of the build strategy to build the container.
<target_image_registry/repository/image:tag>- Specifies the location where you want to push the built image.
<secret_name_for_credentials>- (Optional) Specifies the secret name that stores the credentials for pushing container images. To generate a secret for a private registry for authentication, see Authentication to container registries.
Choose one of the following methods to upload your source code to the required registry and run the build:
Upload the source code using the
shpCLI:Run the following command in the directory containing the local source code. It packages your source code into a scratch container image, pushes it to the required registry, and runs the build:
shp build upload <build_resource_name>
$ shp build upload <build_resource_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
<build_resource_name>-
Specifies the name of the
Buildresource.
Upload the OCI artifact manually:
Create a
Containerfilein the root directory of your source code and add the following configuration:FROM scratch COPY . /
FROM scratch COPY . /Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the following command in the root directory of your source code to build the container image using Podman:
podman build -t <registry_path>/<image_name>:<tag> .
$ podman build -t <registry_path>/<image_name>:<tag> .Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
<registry_path>- Specifies the build location for the registry where the image is stored.
<image_name>- Specifies the name of the container image.
<tag>Specifies the tag of the image.
When the container image is built successfully, a success message is displayed. See the following example command and output:
podman build -t quay.io/example/oci:latest .
podman build -t quay.io/example/oci:latest .Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Push the container image to the required location using the following command:
podman push <registry_path>/<image_name>:<tag>
$ podman push <registry_path>/<image_name>:<tag>Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
<registry_path>- Specifies the build location for the registry where the image is stored.
<image_name>- Specifies the name of the container image.
<tag>- Specifies the tag of the image.
Run the build using the following command:
shp build run <build_resource_name>
$ shp build run <build_resource_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
<build_resource_name>-
Specifies the name of the
Buildresource.
Verification
After all the containers complete their tasks, verify the statuses of the following resources:
Check whether the pod shows the
STATUSfield asCompleted:oc get pods -w
$ oc get pods -wCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
NAME READY STATUS RESTARTS AGE oci-artifact-buildrun-pxg9w-pod 2/2 Running 0 58s oci-artifact-buildrun-pxg9w-pod 0/2 Completed 0 1m42s
NAME READY STATUS RESTARTS AGE oci-artifact-buildrun-pxg9w-pod 2/2 Running 0 58s oci-artifact-buildrun-pxg9w-pod 0/2 Completed 0 1m42sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check whether the respective
TaskRunresource shows theSUCCEEDEDfield asTrue:oc get tr
$ oc get trCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME oci-artifact-buildrun-pxg9w True Succeeded 2m10s 28s
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME oci-artifact-buildrun-pxg9w True Succeeded 2m10s 28sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check whether the respective
BuildRunresource shows theSUCCEEDEDfield asTrue:oc get br
$ oc get brCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME oci-artifact-buildrun True Succeeded 2m12s 30s
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME oci-artifact-buildrun True Succeeded 2m12s 30sCopy to Clipboard Copied! Toggle word wrap Toggle overflow During verification, if a build run fails, you can check the
status.failureDetailsfield in yourBuildRunresource to identify the exact point where the failure happened in the pod or container.NoteThe pod might switch to a
NotReadystate because one of the containers has completed its task. This is an expected behavior.Validate whether the image has been pushed to the registry that is specified in the
build.spec.output.imagefield. Log in to the registry and run the following command to pull the image:podman manifest inspect image-registry.openshift-image-registry.svc:5000/oci-artifacts-example/taxi-app
$ podman manifest inspect image-registry.openshift-image-registry.svc:5000/oci-artifacts-example/taxi-appCopy to Clipboard Copied! Toggle word wrap Toggle overflow In the previous example, the project name is
oci-artifacts-example, and the image name istaxi-app.Example output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 2. Creating container images in a network restricted environment Copy linkLink copied to clipboard!
As an application developer, configure OpenShift Container Platform with an HTTP or HTTPS proxy to enforce security and prevent direct internet access for your build processes. This setup enforces security by routing build pulls of dependencies, images, and code through a monitored outgoing proxy gateway.
2.1. Creating a buildah build in a network-restricted environment Copy linkLink copied to clipboard!
Create a buildah build in a network-restricted environment by mirroring the images that buildah build strategy requires. Mirroring the images eliminates the need for public registry access. This ensures clusters use only images that comply with external content controls.
Prerequisites
-
You have installed the
ocCLI. - Your cluster can connect and interact with the Git source that you can use to create the buildah build.
-
You have the builder-image required to create the
buildahbuild in your local registry. If the builder-image is not present in the local registry, mirror the source image.
Procedure
Run the following command to mirror the images that
buildahbuild strategy requires:oc image mirror --insecure -a <registry_authentication> registry.redhat.io/ubi8/buildah@sha256:1c89cc3cab0ac0fc7387c1fe5e63443468219aab6fd531c8dad6d22fd999819e <mirror_registry>/<repo>/ubi8_buildah
$ oc image mirror --insecure -a <registry_authentication> registry.redhat.io/ubi8/buildah@sha256:1c89cc3cab0ac0fc7387c1fe5e63443468219aab6fd531c8dad6d22fd999819e <mirror_registry>/<repo>/ubi8_buildahCopy to Clipboard Copied! Toggle word wrap Toggle overflow where:
<registry_authentication>- Specifies the authentication credentials used to access a container registry. This is required when pushing to or pulling from a private registry.
<mirror_registry>- Specifies the registry where the image you want to mirror is stored.
<image_name>- Specifies the name of the image.
<tag>- Specifies the tag of the image.
- Perform the steps mentioned in the "Creating a buildah build" section.
2.2. Creating a source-to-image build in a network-restricted environment Copy linkLink copied to clipboard!
Create a source-to-image build in a network-restricted environment by mirroring the images that source-to-image build strategy requires. Mirroring the images eliminates the need for public registry access. This ensures clusters use only images that comply with external content controls.
Prerequisites
-
You have installed the
ocCLI. -
Your cluster can connect and interact with the Git source used to create the
source-to-imagebuild. -
You have the builder-image required to create the
source-to-imagebuild in your local registry. If the builder-image is not present in the local registry, mirror the source image.
Procedure
Run the following command to mirror the images that
source-to-imagebuild strategy requires:oc image mirror --insecure -a <registry_authentication> registry.redhat.io/source-to-image/source-to-image-rhel8@sha256:d041c1bbe503d152d0759598f79802e257816d674b342670ef61c6f9e6d401c5 <mirror_registry>/<repo>/source-to-image-source-to-image-rhel8
$ oc image mirror --insecure -a <registry_authentication> registry.redhat.io/source-to-image/source-to-image-rhel8@sha256:d041c1bbe503d152d0759598f79802e257816d674b342670ef61c6f9e6d401c5 <mirror_registry>/<repo>/source-to-image-source-to-image-rhel8Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
<registry_authentication>- Specifies the authentication credentials used to access a container registry. This is required when pushing to or pulling from a private registry.
<mirror_registry>- Specifies the registry where the image you want to mirror is stored.
<image_name>- Specifies the name of the mirror image.
<tag>- Specifies the tag of the image.
- Perform the steps mentioned in the "Creating a source-to-image build" section.
2.3. Verifying proxy details Copy linkLink copied to clipboard!
If you run a cluster behind a proxy, ensure that cluster-wide proxy settings and environment variables are correctly configured in the OpenShift Container Platform cluster. This ensures all Builds traffic is routed through the monitored outbound proxy gateway.
Prerequisites
-
You have installed the
ocCLI.
Procedure
To verify the cluster-wide proxy settings, run the following command:
oc describe proxy/cluster
$ oc describe proxy/clusterCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To verify the environment variables, run the following command:
oc set env deployment/openshift-builds-operator --list -n openshift-builds | grep PROXY
$ oc set env deployment/openshift-builds-operator --list -n openshift-builds | grep PROXYCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
HTTP_PROXY=http://192.168.130.1:3128 HTTPS_PROXY=https://192.168.130.1:3129 NO_PROXY=.cluster.local,.svc,.testing,10.217.0.0/22,10.217.4.0/23,127.0.0.1,192.168.126.0/24,192.168.1 30.11,api-int.crc.testing,localhost
HTTP_PROXY=http://192.168.130.1:3128 HTTPS_PROXY=https://192.168.130.1:3129 NO_PROXY=.cluster.local,.svc,.testing,10.217.0.0/22,10.217.4.0/23,127.0.0.1,192.168.126.0/24,192.168.1 30.11,api-int.crc.testing,localhostCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 3. Managing Builds Copy linkLink copied to clipboard!
As an application developer, modify or delete the custom resources (CR) that are not used in builds. This helps in maintaining a clean and efficient build configuration.
3.1. Editing the resources Copy linkLink copied to clipboard!
You can edit the resources that are created by buildah, source-to-image and buildpacks build processes using the oc CLI. You can modify the resources as needed in your project.
Prerequisites
-
You have installed the
ocCLI.
Procedure
Run the following command to open the YAML definition in the default editor:
oc edit <resource_name> <build_resource_name>
$ oc edit <resource_name> <build_resource_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
<resource_name>-
Specifies the name of the resource (
build,buildrunorbuildstrategy) <build_resource_name>- Specifies the name of the build resource that you want to edit.
- Edit the YAML definition and save the file.
3.2. Deleting a build resource Copy linkLink copied to clipboard!
Delete a build resource created by the buildah, source-to-image (S2I), and buildpacks build processes using the oc CLI or the shp CLI. This cleanup ensures that unused build configurations are removed, keeping your project organized and efficient.
Prerequisites
-
You have installed the
ocCLI. -
Optional: You have installed the
shpCLI.
Procedure
Delete a
buildresource by using theocCLI orshpCLI:oc delete builds <build_resource_name>
$ oc delete builds <build_resource_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow shp build delete <build_resource_name>
$ shp build delete <build_resource_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
<build_resource_name>-
Specifies the name of the
buildresource.
Verification
Verify that the
buildresource is deleted by using theocCLI orshpCLI:oc get build | grep <build_resource_name>
$ oc get build | grep <build_resource_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow shp build list | grep <build_resource_name>
$ shp build list | grep <build_resource_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
<build_resource_name>Specifies the name of the
buildresource.If the
buildresource is successfully deleted, the commands do not return any output.
3.3. Deleting a buildrun resource Copy linkLink copied to clipboard!
Delete a buildrun resource created by the buildah, source-to-image (S2I), and buildpacks build processes if it is not required in your project. Deleting the resources helps you clean up build configurations that are no longer required in your project.
Prerequisites
-
You have installed the
ocCLI. -
Optional: You have installed the
shpCLI.
Procedure
Delete a
buildresource by using theocCLI orshpCLI:oc delete buildrun <buildrun_resource_name>
$ oc delete buildrun <buildrun_resource_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow shp build list | grep <buildrun_resource_name>
$ shp build list | grep <buildrun_resource_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
<buildrun_resource_name>Specifies the name of the
buildrunresource.If the
buildrunresource has been successfully deleted, the commands do not return any output.
Verification
Verify that the
buildrunresource is deleted by using theocCLI orshpCLI:oc get buildrun | grep <buildrun_resource_name>
$ oc get buildrun | grep <buildrun_resource_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow shp buildrun list | grep <buildrun_resource_name>
$ shp buildrun list | grep <buildrun_resource_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
<buildrun_resource_name>Specifies the name of the
buildrunresource.If the
buildrunresource is successfully deleted, the commands do not return any output.
3.4. Deleting a buildstrategy resource Copy linkLink copied to clipboard!
Delete a buildstrategy resource to remove unused build configurations and keep your project clean and efficient.
Prerequisites
-
You have installed the
ocCLI. -
Optional: You have installed the
shpCLI.
Procedure
Delete a
buildstrategyresource by using theocCLI:oc delete buildstrategy <buildstrategy_resource_name>
$ oc delete buildstrategy <buildstrategy_resource_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
<buildstrategy_resource_name>-
Specifies the name of the
buildstrategyresource.
Verification
Verify that the
buildstrategyresource is deleted by using theocCLI orshpCLI:oc get buildstrategy | grep <buildstrategy_resource_name>
$ oc get buildstrategy | grep <buildstrategy_resource_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow shp buildstrategy list | grep <buildstrategy_resource_name>
$ shp buildstrategy list | grep <buildstrategy_resource_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
<buildstrategy_resource_name>Specifies the name of the
buildstrategyresource.If the
buildstrategyresource has been successfully deleted, the commands do not return any output.
Legal Notice
Copy linkLink copied to clipboard!
Copyright © 2025 Red Hat
OpenShift documentation is licensed under the Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0).
Modified versions must remove all Red Hat trademarks.
Portions adapted from https://github.com/kubernetes-incubator/service-catalog/ with modifications by Red Hat.
Red Hat, Red Hat Enterprise Linux, the Red Hat logo, the Shadowman logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation’s permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.