...

/

Creating an Image Including Files

Creating an Image Including Files

In this lesson, you are going to learn how to include an HTML file in an image.

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


Press + to interact
<html>
<body>
<h1>Hello !</h1>
<div>I'm hosted by a container.</div>
</body>
</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 ...