The S2I toolkit produces ready-to-run images by injecting source files into a running instance of a builder base image, with scripts in the builder image turning that source code into a runnable application. From the container the build process was run in, a runnable application image is then created.
The command-line tool that drives the S2I build process is called s2i. When you deploy an application from source code in OpenShift using S2I, all the steps involved in running the s2i command-line tool are done for you.
To build the container image, run s2i build, supplying it the location of your application source code, the name of the S2I builder image, and the name to give to the application image created:
$ s2i build [location of app source code] [name of image]
Details of the image produced can be viewed by running docker images:
$ docker images
If you encounter an error as shown below while running the s2i command:
s2i: command not found
you may install the below package as per your choice of distribution.
Distribution | Command |
---|---|
OS X | brew install source-to-image |
Fedora | dnf install source-to-image |
Conclusion
The Source-to-Image tool implements a mechanism to take application source code and build it into a container image. The tool works by starting a container using an S2I builder image, injecting the application source code into the container, and running an assemble script to set up the contents of the image.