Home Explore Blog CI



docker

4th chunk of `content/get-started/docker-concepts/running-containers/multi-container-applications.md`
f28b91f4c79eb8a12514929449ddb067f89bffe78e628dba0000000100000e36
8. With everything up and running, you can open [http://localhost](http://localhost) in your browser to see the site. Refresh the page several times to see the host that’s handling the request and the total number of requests:

    ```console
    web2: Number of visits is: 9
    web1: Number of visits is: 10
    web2: Number of visits is: 11
    web1: Number of visits is: 12
    ```

    > [!NOTE]
    >
    > You might have noticed that Nginx, acting as a reverse proxy, likely distributes incoming requests in a round-robin fashion between the two backend containers. This means each request might be directed to a different container (web1 and web2) on a rotating basis. The output shows consecutive increments for both the web1 and web2 containers and the actual counter value stored in Redis is updated only after the response is sent back to the client.

9. You can use the Docker Desktop Dashboard to remove the containers by selecting the containers and selecting the **Delete** button.

   ![A screenshot of Docker Desktop Dashboard showing how to delete the multi-container applications](images/delete-multi-container-apps.webp?border=true)
 
## Simplify the deployment using Docker Compose


Docker Compose provides a structured and streamlined approach for managing multi-container deployments. As stated earlier, with Docker Compose, you don’t need to run multiple `docker run` commands. All you need to do is define your entire multi-container application in a single YAML file called `compose.yml`. Let’s see how it works.


Navigate to the root of the project directory. Inside this directory, you'll find a file named `compose.yml`. This YAML file is where all the magic happens. It defines all the services that make up your application, along with their configurations. Each service specifies its image, ports, volumes, networks, and any other settings necessary for its functionality.

1. Use the `docker compose up` command to start the application:

    ```console
    $ docker compose up -d --build
    ```

    When you run this command, you should see output similar to the following:


    ```console
    Running 5/5
    ✔ Network nginx-nodejs-redis_default    Created                                                0.0s
    ✔ Container nginx-nodejs-redis-web1-1   Started                                                0.1s
    ✔ Container nginx-nodejs-redis-redis-1  Started                                                0.1s
    ✔ Container nginx-nodejs-redis-web2-1   Started                                                0.1s
    ✔ Container nginx-nodejs-redis-nginx-1  Started
    ```

2. If you look at the Docker Desktop Dashboard, you can see the containers and dive deeper into their configuration.


    ![A screenshot of the Docker Desktop Dashboard showing the containers of the application stack deployed using Docker Compose](images/list-containers.webp?border=true)

3. Alternatively, you can use the Docker Desktop Dashboard to remove the containers by selecting the application stack and selecting the **Delete** button.

   ![A screenshot of Docker Desktop Dashboard that shows how to remove the containers that you deployed using Docker Compose](images/delete-containers.webp?border=true)


In this guide, you learned how easy it is to use Docker Compose to start and stop a multi-container application compared to `docker run` which is error-prone and difficult to manage.

## Additional resources

* [`docker container run` CLI reference](reference/cli/docker/container/run/)
* [What is Docker Compose](/get-started/docker-concepts/the-basics/what-is-docker-compose/)


Title: Deploying with Docker Compose and Additional Resources
Summary
This section demonstrates how to access the running application via `http://localhost` and observe Nginx's reverse proxy behavior. It then explains how to remove containers using the Docker Desktop Dashboard. Next, it introduces Docker Compose as a simplified approach to managing multi-container deployments by using a `compose.yml` file. It guides users on starting the application with `docker compose up -d --build`, verifies the running containers via the Docker Desktop Dashboard, and explains how to remove the containers using the dashboard. The section concludes by highlighting the ease of Docker Compose compared to individual `docker run` commands and provides links to additional resources, including the `docker container run` CLI reference and an introduction to Docker Compose.