Creating container images
In this section, we will review the different methods to build container images, along with their pros and cons and use cases, so that you can choose the right one, depending on your needs.
There are three ways to create container images:
- Using a base image within a Dockerfile, which is a recipe file that contains different automated steps that are executed to create an image
- Interactively and manually executing commands and storing the resulting filesystem
- From an empty filesystem, using a Dockerfile recipe file and copying only the binaries and libraries required for our application
It is easy to see that the last method is the best in terms of security, but this can be difficult to implement if your code has many dependencies and is very integrated with operating system files. Let’s explore these methods, starting with the most common.
Using Dockerfiles to create container images
Before we describe this method, let...