Join us

Docker Composer with Nodejs App

1_QqBnMfkMKYgdZWlAyifSww (1).png

Recommendation :) Docker-compose built on top of the Docker container engine. To know more about Docker please follow this article which will give you a good sense to read this article.

What we will do in this article

  1. What is docker-compose? Why and when should we use it?
  2. Installation of docker-compose.
  3. Let's understand our services.
  4. Understand Docker-compose file.
  5. Run these services and access them through localhost.

Step 1: What is docker-compose? Why and when should we use it?

  • Docker compose is built on top of docker.
  • Docker compose solves the repeated work. Like build, deploy the docker files. Like in our above diagram we have three docker containers. So each container will have a build and run process.
  • It helps to reduce human effort. So, fewer errors occur while building and deploying the docker files

Step 2: Installation of docker-compose.

  • If you are using docker desktop to run your docker container then we do not require any extra installation steps.
  • If docker is used from docker CLI then need to follow the following steps.

Step 3: Let’s understand our services.

  • Clone this github repo.
  • Next shift to branch basic-docker-compose
  • We are having three service
    1. Mongodb Service
    2. User Service. => Depends on Mongodb service
    3. Gateway Service => Depends on User service
  • To learn more about repo read this article.

Step 4. Understand Docker-compose file.

  • In this file, we are having docker-compose manifest file.
  • This file just instructs the docker file on where to build and how to run.

Step 5: Run these services and access them through localhost.

  • Run this following command to build and run docker files

  • Next access our application from localhost:3000

Feedback: Thank you for reading this article. I hope you understood the basics of deploying your application from scratch with docker compose. Please feel free to ask questions or give suggestions to improve the content quality. Visit this for all articles.


Only registered users can post comments. Please, login or signup.

Start blogging about your favorite technologies, reach more readers and earn rewards!

Join other developers and claim your FAUN account now!

Avatar

RAKESH KUMAR SHARMA

@airrakesh
Simplifying human life | 👨🏽‍💻
User Popularity
33

Influence

2k

Total Hits

2

Posts