Building Docker images
In the previous sections, we built an image using the commit command of Docker. Although it works, I can see a big problem with it: it is not repeatable. There is no easy way of rebuilding the image once and over again when the software installed in the image is patched due to new vulnerabilities or versions.
In order to solve this problem, Docker provides a better way of building images: Dockerfiles.
A Dockerfile is a file that contains a set of ordered commands required to leave the image, ready to be used. Things such as installing software or upgrading the version of the kernel as well as adding users are common activities that can be carried in a Dockerfile. Let's look at an example:
FROM node:latest RUN mkdir -p /app/ WORKDIR /app/ COPY package.json /app/ RUN npm install COPY . /app EXPOSE 8080 CMD [ "npm", "start" ]
If you have been in the IT field for a few years, you really don't need an explanation on what it is going on, but let's make sure that we are all...