Chapter 7. Building an Image from a Dockerfile

Using an S2I builder to create an application image simplifies the build process, as the builder does all the hard work for you. To make it simple, the author of the S2I builder will have made some decisions in advance about what application server stack is used, how it is configured, and how your application source code needs to be structured.

Although you can override the S2I build and deployment process for an application, the extent of the customizations you can make is restricted. You cannot, for example, install additional operating system packages or run any actions that require root privileges.

In order to have full control over how the image is built and the application run, you will need to use the Docker build strategy.

In this chapter you will learn how you can build a container image in OpenShift from a Dockerfile using the Docker build strategy. The container image produced can be an application image or your own custom S2I builder image.

The Docker Build Strategy

The Docker build strategy takes the instructions from a Dockerfile and uses them to construct a container image. The Dockerfile and associated files required to construct the image need to be in a hosted source code repository accessible to the OpenShift cluster where you perform the builds.

This strategy can be used to construct an application image or an S2I builder image. By having OpenShift perform the build, you avoid the need to have separate infrastructure ...

Get Deploying to OpenShift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.