HW10: Docker Basics due Sat 04 Nov 23:59

\begin{purpose}
The purpose of this assignment is for you to practice interacti...
... with various docker commands, including the use of a Dockerfile.
\end{purpose}

Update the Original Image Manually

In the prelab we found that the offical ubuntu/apache2 image did not have any text editors installed and did not have the systemctl command installed.

Rerun the image that you worked with in the prelab assignment and use the docker exec command to open a shell to the running container. To install your favorite editor, first execute apt update and apt upgrade. Then do an appropriate apt install command. And while you're installing things go ahead and install PHP as well.

Although the systemctl command is not installed there is a command called service that works in a similar way. To check on the status of apache We'll use it instead: service apache2 status.

NOTE: Do not restart apache because it will cause the container to stop.

Create Image from Container and Save It

Now that the running container has been modified lets create an image from it using: docker commit container-id yourid/tag. In this case use a tag name of: mylap (i.e., my linux, apache, php).

You can see the images that exist on your local system with: docker image ls. You should now see the image you just created.

Now we want to transfer this image to your account at hub.docker.com. First you'll need to tell docker your account credentials: docker login. We'll ignore the warning for now. Next you can push your saved image like this:

docker tag image-id yourid/mylap
docker push yourid/mylap

From a browser log in to your DockerHub account and verify that the image is now saved there.

Get Port-Forwarding Figured Out

Stop the original container and remove all containers (not just running ones). Now run the image that you saved in DockerHub. Once it starts, verify it contains the changes you made manually.

We now actually the 3 layers of computing to be aware of:

We want to be able to connect to apache on the container from a browser on the local computer. Since the EC2 server and the container are both running apache on port 80 we'll need to connect a different port on the EC2 server to the container. Then we'll use port forwarding from our local computer to the modified port in EC2 to complete the chain. (Recall discussion of secure phpmyadmin for this last part).

Fiddle with this until you are able to see the default web page in your container from the browser on your local computer.

Create a Dockerfile to Install GuessingGame

Create a Dockerfile that will use your mylap image as a base and will (via the Dockerfile commands) remove the default index.php file and in its place install all the files found in this archive: https://josephus.hsutx.edu/classes/sa/source/guessinggame.tgz

If the Dockerfile works you should be able to play an interesting guessing game in which you can formulate a question to eliminate some of the images. Once you've eliminated an image, click on it to turn it over.

What to Turn In

You should have an image named yourid/mylap available at DockerHub and you should have Dockerfile which when built will produce a container that provides a working guessing game application. To turn in your Dockerfile, make a copy of it and give the copy a .txt extension and then upload into Canvas.