Member-only story

Build Container using Docker Compose — Learning Docker

Izzat Arramsyah
2 min readNov 1, 2022

--

INTRODUCTION

In short, Docker Compose is used to create a container that comprises several Docker images. Without using Docker Compose, if we want to run multiple containers simultaneously within the same network, we need to execute several Docker commands. For example, here we will create a MongoDB container as a database and a Node.js container as a backend. Please clone the Node.js project here as an example

RUN CONTAINER USING DOCKER COMMAND

Before we build the container using Docker Compose, let’s try running the MongoDB container and Node.js backend container using Docker commands.

  1. Build Image Backend Node JS
docker build -t app-name:0.0.1

2. Create Docker Network

docker network create network-name

3. Create Docker Volume

docker volume create volume-name

4. Build Mongo Docker Image using Docker Network & Docker Volume

docker run -p 27017:27017 --network docker-rest-api-network -v docker-rest-api-volume:/data/db -d --name mongo -t mongo:latest

5. Build Node JS Backend Image using Docker Network

docker run -p -p 8000:8000 --network…

--

--

No responses yet