Dockerfile Example: Difference between revisions
Jump to navigation
Jump to search
(Created page with "=Internal= * Dockerfile =Example= <pre> # # Example of very simple Dockerfile based on minimalistic BusyBox base image # Please read through each com...") |
|||
Line 5: | Line 5: | ||
=Example= | =Example= | ||
# | |||
# | # Example of very simple Dockerfile based on minimalistic BusyBox base image | ||
# 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 | ||
# 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 | |||
# 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 | |||
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