Compose Multiple Applications
Learn to compose multi-container applications with docker-compose.
We'll cover the following...
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:
git clone https://github.com/abiodunjames/docker-lessons.git
We then navigate to the multi-container-app/exercise directory in the following way:
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 backendandfrontendneed to be containerized.
- The frontendservice should be able to access the APIs of thebackendservice. This means that thefrontendservice must be able to communicate with thebackendservice.
- Since containers are transient, we need persistent storage—a database—to keep URLs.
- The backend