Building and running a container on a local machine
So far in the chapter, we have discussed Docker elements and have looked at an example of a Dockerfile that is used to containerize a web application. Now, we have all the elements to run Docker.
The execution of Docker is performed by different operations, as outlined here:
- Building a Docker image from a Dockerfile
- Instantiating a new container locally from this image
- Testing our locally containerized application
Let's take a deep dive into each operation.
Building a Docker image
We'll build a Docker image from our previously created Dockerfile that contains the following instructions:
FROM httpd:latest COPY index.html /usr/local/apache2/htdocs/
We'll go to a terminal to head into the directory that contains the Dockerfile, and then execute the docker build
command with the following syntax:
docker build -t demobook:v1 .
The -t
argument indicates the name of the image and...