Do It Yourself - Exercise

A docker-compose exercise to test all you have learnt to far

We'll cover the following

Problem statement#

In this exercise, you will write a docker-compose.yml file to automate the deployment of two services. A skeleton will be provided and you have to join the services and make it work.

The app will be similar to what we have built in this section so you don’t have to deal with the Python code. You only have to focus on creating the docker-compose.yml file.

You can use the terminal below and carry out different troubleshooting commands to check what you are missing and what needs to be fixed.

This exercise will require you to discover some commands on your own, which we have not covered directly in any of the lessons of this section. But you can think and take a reference to the official documentation to solve it.

So, let’s take a look at the skeleton.


Make sure that you don’t make any changes in any other file except docker-compose.yml. All the changes required to solve this exercise are in the docker-compose.yml file only. You can read the app.py file for DB credentials used by the application.

If your changes are not reflected in the terminal after making changes to files then consider restarting the terminal. To restart the terminal follow the below steps:

  1. Type docker stop educative. This command will disconnect the current terminal.
root@educative:/exercise_3# docker stop educative
Terminal Disconnected: Run again to reconnect.
  1. Click on the “Run” button again.

This should solve the problem.

Also, if you are using the below educative terminal then, for security reasons the code written in the below editor will be available in /usercode directory only. So, consider using the /usercode directory to mount it to the container file system. Mounting the present working directory (For this exercise PWD is exercise_3) will not work.

/
db
templates
.flaskenv
Dockerfile
README.md
app.py
docker-compose.yml
requirements.txt
Your app can be found at: https://811lgmnxmw1xy.educative.run

If you have not practiced the lessons and never done any troubleshooting before, this exercise might take a long time. But it will be easy for those who have understood the architecture and role of every component of docker-compose and Docker.

So, I wish you all the best for this exercise. I hope you will learn something new by doing it.

Quiz on Docker Compose Concepts
Solution
Mark as Completed
Report an Issue