Introducing Dockerfiles
In this section, we will cover Dockerfiles in depth, along with the best practices when it comes to their use. So, what is a Dockerfile?
A Dockerfile is simply a plain text file that contains a set of user-defined instructions. When a Dockerfile is called by the docker image build
command, which we will look at next, it is used to assemble a container image.
A Dockerfile looks as follows:
FROM alpine:latest LABEL maintainer=”Russ McKendrick <[email protected]>” 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.conf COPY files/default.conf /etc/nginx/conf.d/default.conf ADD files/html.tar.gz /usr/share/nginx/ EXPOSE 80/tcp ENTRYPOINT [“nginx”] CMD [“-g”, “daemon off;”]
As you can...