To create your own Docker image you will need to create a Dockerfile.
A Dockerfile defines the layers that will be assembled to create the final image.
Let's take a look at a simple Dockerfile.
Our Dockerfile consists of two instructions:
This instructions tells Docker that we want to extend the official Nginx image.
COPY index.html /usr/share/nginx/html/index.html
This instructions tells Docker to copy a file into the image.
Now let's build the image and call it
docker build -t simple resources/simple
And let's now run a container based on our image:
docker run --name simple -d -p 80:80 simple
Visit https://[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/ to see the website. You should see "Hello, World!".
You can now cleanup with
docker stop simple && docker rm simple.
Want to try something? Change the contents of
resources/simple/index.htmland rebuild the image. Run a container based on the new image and see that the contents have now changed.