In order to make this script available in the image, we use the ADD keyword here. It is the main program to be executed after the container is started. Line 15: the run-httpd.sh is a script for bootstraping the HTTPd service. Line 14: comments in Dockerfile are started with the #. Line 12: we know that the HTTPd service will run on port number 80, we expose that port explicitly for the connectivity. It is done by using the RUN keyword followed by the actual YUM command. Line 8-10: given that we want to build a image for running the Apache HTTPd server, we uses the YUM package manager to install the httpd package within the container. For instance, the MAINTAINER and LABEL attributes are provided in the example. Line 2-3: a container image can be created with metadata. In this example, the basis image is the official CentOS 7 image from the Docker Hub. Line 1: all container images are built from a basis image.
It started with a keyword followed by argument(s). Yum -y -setopt = tsflags =nodocs install httpd & \ĮXPOSE 80 # Simple startup script to avoid some issues observed with container restart ADD run-httpd.sh /run-httpd.sh RUN chmod -v +x /run-httpd.shĮach line of the Dockerfile is taken as a step of the build. RUN yum -y -setopt = tsflags =nodocs update & \ LABEL Vendor = 'CentOS' \ License =GPLv2 \ Version = 2.4.6-40 FROM centos:7 MAINTAINER The CentOS Project