Compose Multiple Applications

Learn to compose multi-container applications with docker-compose.

BitLink is a URL-shortening and link management application that takes a big URL and converts it into a new short URL that’s easy to share. A database is required for such an application to store and maintain a map of shortened URLs and their original URLs. A simple version of a URL-shortening application could have a microservice that generates shortened URLs and another microservice that displays the URL to the user

Let’s refer to the services as backend and frontend services.

We use an existing codebase to create a multi-container application for this type of application.

If we haven’t cloned the project yet, we do so now on GitHub with the following command:

Press + to interact
git clone https://github.com/abiodunjames/docker-lessons.git

We then navigate to the multi-container-app/exercise directory in the following way:

Press + to interact
cd multi-container-app/exercise

There are two directories named backend and frontend. The backend directory contains the back-end code, which exposes the API for generating shortened URLs. The front-end code—which is responsible for the user interface—is located in the frontend directory. There are a few prerequisites that must be met before we can run the applications with docker-compose.

  • Both the backend and frontend need to be containerized.
  • The frontend service should be able to access the APIs of the backend service. This means that the frontend service must be able to communicate with the backend service.
  • Since containers are transient, we need persistent storage—a database—to keep URLs.
  • The backend
...