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...") |
No edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
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 | ||
# Docker will pull from docker.io if base image does not already exist in local Docker repo | # | ||
# | FROM busybox | ||
FROM busybox | |||
MAINTAINER "Nova Ordis" | |||
MAINTAINER "Nova Ordis" | |||
# | |||
# | # The LABEL instruction adds metadata to an image. A LABEL is a key-value pair. | ||
# The LABEL instruction adds metadata to an image. A LABEL is a key-value pair. | # | ||
# | LABEL version="1.0" \ | ||
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 | ||
# Define two environment variables: NAME and TARGET_DIR | # Value of env variables can be modified at container startup using -e parameter | ||
# Value of env variables can be modified at container startup using -e parameter | # | ||
# | ENV NAME="NovaOrdis OpenShift Test Environment" \ | ||
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 | ||
# Docker is to execute all subsequent commands in this file as BusyBox's root user | # | ||
# | USER root | ||
USER root | |||
# | |||
# | # /usr/local/bin/ is included in the root user's $PATH, so copy our shell script to this directory | ||
# /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 | ||
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 | # | ||
# | RUN chmod 755 /usr/local/bin/run-loop.sh | ||
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 | ||
# Create directory and define it as a container mount point. Our shell script will write output | # to local filesystem at this mount point. | ||
# to local filesystem at this mount point. | # | ||
# | [[Dockerfile#RUN|RUN]] mkdir $TARGET_DIR | ||
[[Dockerfile#VOLUME|VOLUME]] $TARGET_DIR | |||
VOLUME $TARGET_DIR | |||
# | |||
# | # At startup, this container should run a single command. Our script uses the command line | ||
# At startup, this container should run a single command. Our script uses the command line | # parameters passed as part of $NAME env var | ||
# parameters passed as part of $NAME env var | # | ||
# | CMD /usr/local/bin/run-loop.sh $NAME | ||
CMD /usr/local/bin/run-loop.sh $NAME | |||
Latest revision as of 01:14, 1 February 2018
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. # RUN 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