Utah Tech Logo

IT3300

DevOps virtualization

IT 3300 : Virtualization

Docker Compose - group work

Example 1

Bring it up using the appropriate docker compose command

Example 1 Questions

  1. What is the name of the volume that the app uses? Where is the path to it on your local machine?
  2. What container is is mounted to?
  3. What container(s) are using a bind mount? What is the name of the folder that is shared in this mount?
  4. What port do you need to visit to access the web application?
    • after you navigate to the correct web port, open a terminal to the same machine and execute a curl command in a loop, like:
    • for i in {1..100}; do curl -X POST http://localhost:PORTNUMBERHERE -d "vote=a"; done
    • You should be able to view some changes in the results
  5. Why do all the containers start with example-voting-app? Change it to app-for-voting.
  6. What networks exist for the application? What kind of networks are they? What ip space are they using? What containers are attached?
  7. What happens if you kill the redis container? Does it affect any other containers? Why?

Example 2

You should utilize docker-compose to make the following work. I have created two docker images that you should use:

You should use the docker compose file to set the environment variables.

The environment variables that MUST be set on the sweb are DB_NAME, DB_USERNAME, DB_PASSWORD, DB_HOST. (Hint: The DB_NAME should be set to hobbits). Remember that the hostname should be set to whatever you have named the mysql host in your docker-compose file.

For the mysql container, you must set the MYSQL_USER, MYSQL_DATABASE and MYSQL_PASSWORD variables. The database variable should be set to hobbits.

You would visit index.php on your website to see if you can see the php stuff run. You should see a list of car makes and be able to add/delete them. You will have an error, look at the logs of your containers to see if you can figure out how to fix the error.

Example 3

Make a copy of the previous example. See if you can bring up both containers without using docker compose. You need to be comfortable setting environment variables in the Dockerfile.

Example 4

Create a simple dockerfile like this:

    FROM ubuntu
    ENV MSG="This is a message for the exam"
    CMD echo $MSG

Build it. Run it. Verify the message that prints out. Now, utilize a docker compose file to run the same image and set an environment variable of the same name in the compose file. Run it. What do you notice about what prints out? You may have to look at the logs.