docs.intersystems.com
InterSystems IRIS Data Platform 2019.2  /  First Look: InterSystems Products in Docker Containers  /  Try It! Create Your Own InterSystems IRIS-based Container

InterSystems: The power behind what matters   
Search:  


Build an InterSystems IRIS-based Image Using a Dockerfile
Committing a running container is a convenient way to save changes for testing purposes or as a minor delta. But the preferred method for creating a production image is to define the image in a Dockerfile and then build it using the docker build command, which
In this section you will create a Dockerfile based on your modified InterSystems IRIS image and use it to build a new image that installs an application with InterSystems IRIS, In the next, Run and Investigate the InterSystems IRIS-based Container, you will run a container from this image that uses durable %SYS, a feature of InterSystems IRIS containers that lets you save instance-specific data outside the container, and investigate it.
Each Dockerfile specifies an existing base image which provides (at a minimum) the runtime environment for whatever is to be executed in the container; if the base image contains installed software, that software is also included in the image built from the Dockerfile. For example, if you use the InterSystems IRIS image from InterSystems as a base, the resulting image inherits the Ubuntu 18.04 LTS runtime environment on which the InterSystems image is based and includes an installed InterSystems IRIS instance. To this you can add specifications for everything needed to add your application — for example, copying or downloading files, setting environment variables, installing the application, and launching the application.
Before creating your Dockerfile, choose or create a very simple application to install in the container and identify or create an installer to be copied into the Dockerfile. To make it easy, you can use the example that follows — a command to create a file. In the Dockerfile for a production image, you might install your InterSystems IRIS-based application instead.
To build your InterSystems-IRIS image, follow these steps:
  1. Using your favorite text editor, create a file named Dockerfile containing the following contents. The image you specify in the FROM statement should be iris2, the one you created by committing the container you modified in Change the Instance and Commit the Container as a New Image. If you have a simple application to install, replace the RUN command shown with one installing that application.
    # Build from the modified IRIS image
    FROM acme/iris2:test
    
    # create a demo file
    RUN echo "This is the file added to the image" > /demo.txt 
  2. Issue the docker build command, specifying the build context (the location of the Dockerfile) and naming and tagging the resulting image (you may need to run this command with root privileges):
    $ docker build /nethome/pmartinez --tag acme/iris3:test
    Sending build context to Docker daemon  478.1MB
    Step 1/2 : FROM intersystems/iris:stable
     ---> 15627fb5cb76
    Step 2/2 : RUN echo "This is the file added to the image" > /demo.txt
     ---> Running in 000b94705814
     ---> 64350c828716
    Removing intermediate container 000b94705814
    Successfully built 64350c828716
    Successfully tagged iris3:test
    
  3. When the image has built successfully, list the available images
    $ docker images
    REPOSITORY           TAG            IMAGE ID          CREATED        SIZE
    acme/iris3           test           64350c828716      9 seconds ago  1.44
    acme/iris2           test           421f6ca16b40      1 hour ago     1.40GB
    acme/iris            stable         15627fb5cb76      3 days ago     1.39GB
    centos               7.3.1611       262f7381844c      2 weeks ago    192MB
    hello-world          latest         05a3bd381fc2      7 months ag    1.84kB
    
Note:
In addition to the base specified by FROM, you can always use a RUN statement to install additional Linux packages using the apt-get command. For example, to include in the image the fortune command with the fortune-debian-hints package to display hints about using Debian distributions, you could include:
RUN apt-get update -y && apt-get install -y fortunes-debian-hints && rm -rf /var/lib/apt/lists/*
Updating apt-get before running it, as shown in this example, is a best practice that helps avoid errors in building your image.


Send us comments on this page
View this article as PDF   |  Download all PDFs
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-09-19 06:44:29