Skip to main content
Welcome — in this lesson we’ll explore OpenShift BuildConfigs and show how to create a new build configuration that switches from a Source (S2I) strategy to a Docker strategy. We will:
  • Inspect an existing BuildConfig in the web console
  • Export and simplify the BuildConfig YAML
  • Change the strategy to Docker and create a matching ImageStream
  • Start the build and validate the result

Inspect the existing BuildConfig

In the OpenShift console, navigate to the project and open Builds → Build Configs. For this demo the existing BuildConfig is simple-webapp-docker. Clicking the build shows each run, logs, and the Configuration tab where you can inspect details such as:
  • Build strategy (e.g. Source / Source-to-Image)
  • Source repository (Git URL)
  • Output location (ImageStreamTag)
  • Webhooks that can trigger builds
  • Environment variables and build events
Example configuration summary visible in the console:

Export the BuildConfig YAML and simplify it

Use the console Actions → Edit YAML to export the BuildConfig. The exported YAML contains generated metadata and many fields you don’t need for creating a new BuildConfig (annotations, creationTimestamp, resourceVersion, selfLink, uid, etc.). Strip out these generated fields and keep only the fields required for your new BuildConfig. Example of an exported BuildConfig (full of generated metadata):
Table — Common BuildConfig fields you should keep or change:

Prepare the repository

Before switching to Docker strategy, ensure your Git repo contains a Dockerfile at the repository root (or at the path you reference). DockerStrategy builds use the repository Dockerfile to perform the build.
DockerStrategy builds require a Dockerfile in the repository. Make sure your repo has a valid Dockerfile committed before triggering the Docker build.

Minimal BuildConfig using Docker strategy

After removing unnecessary metadata and updating fields, create a minimal BuildConfig that:
  • Uses the same Git repository
  • Outputs to simple-webapp-docker:latest
  • Uses Docker as the build strategy
Notes:
  • strategy.type: Docker specifies the Docker build strategy.
  • dockerStrategy: {} is acceptable when the Dockerfile in the repo defines the build. Add properties such as forcePull if needed.
  • The output.to image stream tag must exist (or be creatable) in the project before the BuildConfig can start a build.

Create the ImageStream for the output

If the BuildConfig refers to an ImageStreamTag that doesn’t yet exist (e.g. simple-webapp-docker:latest), the web console may show an error like “invalid output reference” when you try to import the BuildConfig YAML. Create the ImageStream first. Minimal ImageStream YAML:
Import or create the ImageStream in the console (Add to Project → Import YAML/JSON → paste YAML → Create) or apply it with oc apply -f imagestream.yaml.
A screenshot of the OpenShift Origin web console showing a modal dialog that says "Image stream simple-webapp-docker has been imported." The dialog displays import results and a link to continue to the project overview.

Start the build

Once the ImageStream exists and the BuildConfig is applied, start the build manually or wait for a webhook/trigger:
Watch the build logs in the console or with:
The logs should show Docker build steps executed by OpenShift. When the build finishes successfully, the image will be pushed to the simple-webapp-docker:latest ImageStreamTag and can be consumed by DeploymentConfigs or other resources.

Troubleshooting

  • Error importing BuildConfig: create the referenced ImageStream first.
  • Docker builds failing: verify the repository contains a valid Dockerfile and the Dockerfile path matches spec.source.contextDir if used.
  • Image pull or push permission issues: ensure the project has permissions and the internal registry is reachable.
This process lets you convert an existing Source (S2I) BuildConfig into a Docker strategy BuildConfig with minimal YAML changes and the required ImageStream in place.

Watch Video