Docker challenge

Docker volumes 1 - beginner level

This exercise is part of the Docker inside out course.

Task 1

Create a file called index.html in your working directory with the following content:

Start a container using the image „alpine" with an internal volume with the path „/usr/share/nginx/html" and give it the name „ storage".

Then create a container using the nginx image version 1.13.5-alpine and use the volume provided by the storage container. Call the nginx container „ nginx-alpine".

Make sure that the nginx-alpine container uses the created index.html.
(Hint: browse the index.html page from the host command line)

The solution:

Step 1

Create the storage container with the following command:

Step 2

Create the NGINX container with the desired name and image version:

Step 3

Look up the IP address using a filter on the output of the created nginx-alpine container with the following command:

You will get an output like this (your IP address may be different according to your settings and number of running containers):

Step 4

Reach the default index.html file from the nginx-alpine container:

You should see a „403 Forbidden" message (instead of the freshly made index.html) because the directory from the storage container is empty.

Step 5

To use our index.html copy it into the storage container:

Step 6

Look for the web page again and it should give back your index.html.

You could also copy your index.html into the storage container right after creating it, of course. We just wanted to demonstrate the change.

Go to the Docker inside out course