03. Docker Compose

Parmeshwar C
2 min readJan 16, 2021

--

There are several approaches to integrate dockers according to the project structure.

Docker-compose approach

  1. In this approach, each module (web, server, database) resides in different containers.
  2. We have to write different docker files for each
  3. There will be different images for each also.
  4. Only the thing is docker-compose is another top-level file that binds and connects all those images in one project.
  5. It is the standard approach that helps in the micro-system approach.
  6. Here initially we have tried it for our project and then switched to another approach.

How docker-compose works?

  1. Use YAML files to configure application services (docker-compose.yaml)
  2. Can start all the services with a single command ( docker-compose up )
  3. Can stop all the service with a single command ( docker-compose down )
  4. Able to scale up the specific services when required.
  5. Works in all environments: production, staging, development, testing, as well as CI workflows

Docker-compose file looks like

version: '3'services:
neo4j:
build: ./db
image: "db:1.0"
ports:
- 7474:7474
environment:
- NEO4J_dbms_shell_enabled=true
api:
build: ./server
image: "server:1.0"
ports:
- 4001:4001
environment:
- NEO4J_URI=bolt://neo4j:7687
links:
- neo4j
depends_on:
- neo4j
ui:
build: ./web
image: "web:1.0"
ports:
- 3000:3000
environment:
- CI=true

links:
- api
depends_on:
- api
  1. db — it is a database used by the project
  2. server — It is a server-side module
  3. web — it is web side module.
  4. Build, image, port, environment are configurations which helps in building image and linking images with each other.

For more details about the docker-compose approach and implementation go through the following reference links.

  1. https://docs.docker.com/compose/
  2. https://www.tutorialspoint.com/docker/docker_compose.htm

--

--

Parmeshwar C
Parmeshwar C

Written by Parmeshwar C

Software Engineer. (Mobile and Web)

No responses yet