Sidharth R
  • Home
  • Posts
  • Journal
  • Home
  • Posts
  • Journal
  • Search
  1. Home
  2. Posts
  3. Docker Compose Basic

Docker Compose Basic

Updated: 01 Jul 2026 ⚬ Page views: loading...

Introduction

In this lab, you’ll first deploy an application by setting up network, multiple containers individually. Then you will clean up resources, and deploy the same application using Docker Compose.

Task 1: Create a Bridge Network

Create a bridge network named clicknet.

BASH
docker network create --driver bridge clicknet

Verify

list docker networks
$ docker network ls
NETWORK ID     NAME       DRIVER    SCOPE
5aa54ade2dcc   bridge     bridge    local
fc40bfcbce91   clicknet   bridge    local
238b23f4e2a9   host       host      local
59b9cbf97489   none       null      local

Task 2: Run a Redis Container

Create a background container named redis using the redis:alpine image and attach it to the clicknet network.

BASH
docker run -d \
  --name redis \
  --network clicknet \
  redis:alpine

Task 3: Run the Click Counter App

Create a container named clickcounter using the kodekloud/click-counter image, attach it to clicknet, and publish the application’s port (5000) on host port 8085.

BASH
docker run -d \
  --name clickcounter \
  --network clicknet \
  -p 8085:5000 \
  kodekloud/click-counter

Task 4: Clean Up

Remove the containers and network.

BASH
docker rm -f redis clickcounter
BASH
docker network rm clicknet

Task 5: Deploy with Docker Compose

Create a compose.yaml file in clickcounter with the following services:

  • redis

    • Image: redis:alpine
  • clickcounter

    • Image: kodekloud/click-counter
    • The application listens on port 5000.
    • Expose it on host port 8085.

Solution

compose.yaml
services:
  redis:
    image: redis:alpine
  clickcounter:
    image: kodekloud/click-counter
    ports:
    - 8085:5000
    depends_on:
    - redis

Start the stack:

BASH
docker compose up -d

Keep reading

  • Docker Environment Variables and Networking
  • Publishing Ports in Docker
  • Container Cpu Limit Configuration
  • Docker Basic Commands

  • Home
  • Posts
  • Journal
  • Quotes
  • Links worth your time
  • About
  • Contact
  • Style guide
  • RSS
© 2026 Sidharth R.
Licensed CC BY-NC-SA 4.0