Creating Docker images
In Chapter 2, Getting to Know Node.js and MongoDB, we learned that in the Docker platform, we use Docker images to create containers, which can then run services. We have already learned how to use the existing mongo
image to create a container for our database service. In this section, we are going to learn how to create our own image to instantiate a container from. To do so, we first need to create a Dockerfile, which contains all the instructions needed to build the Docker image. First, we will create a Docker image for our backend service and run a container from it. Then, we will do the same for our frontend. Finally, we will create a Docker Compose file to start our database and backend services together with our frontend.
Creating the backend Dockerfile
A Dockerfile tells Docker step by step how to build the image. Each line in the file is an instruction telling Docker what to do. The format of a Dockerfile is as follows:
# comment INSTRUCTION...