> For the complete documentation index, see [llms.txt](https://asafahmadov.gitbook.io/cloud-and-devops/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://asafahmadov.gitbook.io/cloud-and-devops/devops-bootcamp/containers-with-docker/docker-compose-run-multiple-docker-containers.md).

# Docker Compose - Run multiple Docker containers

### What is Docker Compose?

Docker Compose is a tool for defining and running multiple docker containers.

YAML file to configure your application's services:&#x20;

![](https://2601183865-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8QpIzz6VwCOTMwaqKYa3%2Fuploads%2F2lZqYKdXXBY7UVxJs2h5%2Fimage.png?alt=media\&token=d81f53a4-3439-4c72-8d90-0788a80f066e)

Docker Compose automatically creates a common docker network for docker containers in it (--net option in docker run)&#x20;

You can maintain and update configuration more easily than with docker run command

### **Starting the application** with Docker Compose

{% code title="mongo.yaml" %}

```
services:
  mongodb:
    environment:
      - MONGO_INITDB_ROOT_USERNAME=admin
      - MONGO_INITDB_ROOT_PASSWORD=password
    image: mongo
    ports:
      - "27017:27017"
  mongo-express:
    environment:
      - ME_CONFIG_MONGODB_ADMINUSERNAME=admin
      - ME_CONFIG_MONGODB_ADMINPASSWORD=password
      - ME_CONFIG_MONGODB_SERVER=mongodb
    image: mongo-express
    ports:
      - "8080:8081"

version: "3"
```

{% endcode %}

✅ Step 1: start mongodb and mongo-express

```
docker-compose -f mongo.yaml up
```

{% hint style="info" %}
*You can access the mongo-express under localhost:8080 from your browser*
{% endhint %}

✅ Step 2: in mongo-express UI - create a new database “my-db”

✅ Step 3: in mongo-express UI - create a new collection “users” in the database “my-db”

✅ Step 4: start node server

```
cd app
npm install
node server.js
```

✅ Step 5: access the nodejs application from browser

```
http://localhost:3000
```
