DevOps virtualization
git clone https://github.com/dockersamples/example-voting-app.git
Bring it up using the appropriate docker compose command
for i in {1..100}; do curl -X POST http://localhost:PORTNUMBERHERE -d "vote=a"; done
example-voting-app
? Change it to app-for-voting
.You should utilize docker-compose to make the following work. I have created two docker images that you should use:
hobbits
that has a table and some data in it.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.
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.
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.