Dockerfile Example: Difference between revisions
Jump to navigation
Jump to search
Line 22: | Line 22: | ||
LABEL version="1.0" \ | LABEL version="1.0" \ | ||
description="A project that creates a custom Docker image based on a BusyBox base image" | description="A project that creates a custom Docker image based on a BusyBox base image" | ||
# | # | ||
# Define two environment variables: NAME and TARGET_DIR | # Define two environment variables: NAME and TARGET_DIR | ||
Line 29: | Line 29: | ||
ENV NAME="NovaOrdis OpenShift Test Environment" \ | ENV NAME="NovaOrdis OpenShift Test Environment" \ | ||
TARGET_DIR="/var/novaordis" | TARGET_DIR="/var/novaordis" | ||
# | # | ||
# Docker is to execute all subsequent commands in this file as BusyBox's root user | # Docker is to execute all subsequent commands in this file as BusyBox's root user | ||
Line 39: | Line 39: | ||
# | # | ||
COPY run-loop.sh /usr/local/bin/run-loop.sh | COPY run-loop.sh /usr/local/bin/run-loop.sh | ||
# | # | ||
# Ensure that shell script added to image is set as executable | # Ensure that shell script added to image is set as executable |
Revision as of 05:12, 20 November 2017
Internal
Example
# # Example of very simple Dockerfile based on minimalistic BusyBox base image # Please read through each comment to gain a better understanding of what this Dockerfile does # # # Docker will pull from docker.io if base image does not already exist in local Docker repo # FROM busybox MAINTAINER "Nova Ordis" # # The LABEL instruction adds metadata to an image. A LABEL is a key-value pair. # LABEL version="1.0" \ description="A project that creates a custom Docker image based on a BusyBox base image" # # Define two environment variables: NAME and TARGET_DIR # Value of env variables can be modified at container startup using -e parameter # ENV NAME="NovaOrdis OpenShift Test Environment" \ TARGET_DIR="/var/novaordis" # # Docker is to execute all subsequent commands in this file as BusyBox's root user # USER root
# # /usr/local/bin/ is included in the root user's $PATH, so copy our shell script to this directory # COPY run-loop.sh /usr/local/bin/run-loop.sh # # Ensure that shell script added to image is set as executable # RUN chmod 755 /usr/local/bin/run-loop.sh # # Create directory and define it as a container mount point. Our shell script will write output # to local filesystem at this mount point. # CMD mkdir $TARGET_DIR VOLUME $TARGET_DIR # # At startup, this container should run a single command. Our script uses the command line # parameters passed as part of $NAME env var # CMD /usr/local/bin/run-loop.sh $NAME