Containers and cloud-native solutions with Docker
While using a VM is a good option, it is not the best option for many applications. Currently, containers are the most popular way to deploy applications. Containers are lightweight, portable, and easy to use. In this section, we will learn how to deploy a Node.js application using Docker.
We covered the basics of Docker in previous chapters and we have been using Docker and Docker Compose to run the MongoDB database. We now need to learn how to create a Docker image for our application and how to deploy it.
Docker lifecycle
We need to have a clear understanding of the Docker lifecycle to use it properly. Let’s start with a brief introduction. In the following figure, we can see the Docker lifecycle:
Figure 17.1 – Docker lifecycle diagram
We need to start with a Dockerfile,
which is a file that contains the instructions to build the image. Then, we can build the image with the docker...