This is a cache of https://docs.openshift.com/container-platform/3.6/dev_guide/migrating_applications/S2I_tool.html. It is a snapshot of the page at 2024-11-21T03:45:28.886+0000.
<strong>s2i</strong> Tool - Migrating Applications | Developer Guide | OpenShift Container Platform 3.6
×

Overview

The Source-to-Image (s2i) tool injects application source code into a container image and the final product is a new and ready-to-run container image that incorporates the builder image and built source code. The s2i tool can be installed on your local machine without OpenShift Container Platform from the repository.

The s2i tool is a very powerful tool to test and verify your application and images locally before using them on OpenShift Container Platform.

Creating a Container Image

  1. Identify the builder image that is needed for the application. Red Hat offers multiple builder images for different languages including Python, Ruby, Perl, PHP, and Node.js. Other images are available from the community space.

  2. s2i can build images from source code in a local file system or from a Git repository. To build a new container image from the builder image and the source code:

    $ s2i build <source-location> <builder-image-name> <output-image-name>

    <source-location> can either be a Git repository URL or a directory to source code in a local file system.

  3. Test the built image with the Docker daemon:

    $ docker run -d --name <new-name> -p <port-number>:<port-number> <output-image-name>
    $ curl localhost:<port-number>
  4. Push the new image to the OpenShift registry.

  5. Create a new application from the image in the OpenShift registry using the oc command:

    $ oc new-app <image-name>