Using a Dockerfile to build a container image

The first method that we are going to look at for use in building your base container images is by creating a Dockerfile. In fact, we will be using the Dockerfile from the previous section and then executing a docker image build command against it to get ourselves an nginx image. So, let's start off by looking at the Dockerfile once more:

FROM alpine:latestLABEL maintainer="Russ McKendrick <russ@mckendrick.io>"LABEL description="This example Dockerfile installs NGINX."RUN apk add --update nginx && \ rm -rf /var/cache/apk/* && \ mkdir -p /tmp/nginx/COPY files/nginx.conf /etc/nginx/nginx.confCOPY files/default.conf /etc/nginx/conf.d/default.confADD files/html.tar.gz /usr/share/nginx/EXPOSE 80/tcp ...

Get Mastering Docker - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.