IT 3300 : Virtualization
Docker Compose - group work
Example 1
git clone https://github.com/dockersamples/example-voting-app.git
Bring it up using the appropriate docker compose command
Example 1 Questions
- What is the name of the volume that the app uses? Where is the path to it on your local machine?
- What container is is mounted to?
- What container(s) are using a bind mount? What is the name of the folder that is shared in this mount?
- 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
- Why do all the containers start with
example-voting-app
? Change it to app-for-voting
.
- What networks exist for the application? What kind of networks are they? What ip space are they using? What containers are attached?
- 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:
- joelongtoe/smysql
- contains a mysql database named
hobbits
that has a table and some data in it.
- joelongtoe/sweb
- built on ubuntu, has apache and php stuff installed.
- has some files in /var/www/html that will connect to the database assuming the correct environment variables are set.
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:
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.