O'Reilly logo

Mastering Docker - Third Edition by Scott Gallagher, Russ McKendrick

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required