Creating an Image Including Files
Explore how to create Docker images that include external files by using the COPY instruction in a Dockerfile. Understand how to build on existing base images like NGINX to serve web pages, manage Docker build contexts, and run containers that expose services to your local environment.
We'll cover the following...
The image we just created in the previous lesson didn’t need anything other than what the base image already contained, which is why our Dockerfile file was so simple. In a real-world scenario, however, I’m very likely to want files to be part of an image I create.
Suppose I have a file named index.html on my disk with the following contents:
index.html
I want to create an image that includes a web server that serves the above page over HTTP. NGINX is a good candidate. I could keep using the debian base image and add instructions to my Dockerfile file that install NGINX, but it’s easier to base my work on images that are already configured and tested. The Docker Hub contains an NGINX image ...