O'Reilly logo

Build Your Own PaaS with Docker by Oskar Hane

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a parameterized image

Just to get the hang of this feature, which is very good, let's create a small Docker image that converts a string to uppercase or lowercase, depending on the state of an environment variable.

The Docker image will be based on the latest Debian distribution and will have only an ENTRYPOINT command. This is the Dockerfile:

FROM debian:latest
ADD ./case.sh /root/case.sh
RUN chmod +x /root/case.sh
ENTRYPOINT /root/case.sh

This takes the case.sh file from our current directory, adds it to the container, makes it executable, and assigns it as ENTRYPOINT.

The case.sh file may look something like this:

#!/bin/bash

if [ -z "$STR" ]; then
        echo "No STR string specified."
        exit 0
fi

if [ -z "$TO_CASE" ]; then
 echo "No TO_CASE ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required