Starting from:
$25

$19

Homework 4: Dockerfile and Docker Compose (docker-compose.yml)

Total points = 20

This homework is in two parts.
Part 1 = 10 points
Part 2 = 10 points

Part 1 will be to create a simple web server container using the given app.js file that serves up a text string.
       This part will only require a single Dockerfile.

Part 2 will be to create a container that writes a random fortune text to a volume shared with an Nginx webserver container.
       The Nginx webserver container serves up the random fortune text string.
       You will use the Linux "fortune" program and the open source "nginx" container available on the Internet. 
       You will need to install them as part of your Docker container and compose builds.
       This part is a combination of Dockerfile and docker-compose.yml files.  A total of 2 files.


Part 1: (10 points)
1. Create a Dockerfile for "app.js" with an editor like vi.
2. Show the contents of the Dockerfile vi "$ cat Dockerfile".
3. Perform a Docker build and create an image named "hw4-part1" with the "latest" tag.
4. Use Docker to create and run a container called "hw4-part1-c" using the image "hw4-part1".
   Make sure that you map the container's port 8080 to the host's port 8080.
   Note: The app.js program listens to port 8080.
5. Within your laptop's host OS run "curl localhost:8080".
   Show the output of curl.
6. Show the output of "docker image ls".
7. Show the output of "docker container ls".
8. Explain the results of 5, 6, and 7 above.


Part 2: (10 points)
1. Create a Dockerfile for "fortune.sh" with an editor like vi.
2. Show the contents of the Dockerfile vi "$ cat Dockerfile".
3. Perform a Docker build and create an image named "hw4-fortune" with the "latest" tag.
4. Create a docker-compose.yml with an editor like vi and include the following in it.
   a. A shared volume named "hw4-vol".
   b. A service/container named "hw4-fortune-s" using image "hw4-fortune" with the "latest" tag.
      It uses the shared volume "hw4-vol" and mounts to it the file path "/var/local/output".
   c. A service/container named "hw4-nginx-s" using and image "nginx" with the "alpine" tag..
      It uses the the shared volume "hw4-vol" and mounts to it the file path "/usr/share/nginx/html".
      Map this service's internal port 80 to the host's port 80.
5. Within your laptop's host OS run "curl localhost:80" (the ":80" is optional).
   Show the output of curl.
6. Show the output of "docker image ls".
7. Show the output of "docker container ls".
8. Show the output of "docker volume ls".
9. Show the output of "docker network ls".
10. Explain the results of 5, 6, 7, 8 and 9 above.

More products