Start a Cluster of Redpanda Brokers with Redpanda Console in Docker

This Docker Compose example starts three Redpanda brokers and Redpanda Console.

This Docker Compose file is also used in the Redpanda Quickstart.

Prerequisites

You must have Docker and Docker Compose installed on your host machine.

Run the lab

  1. Download the following Docker Compose file on your local file system.

    Reveal the Docker Compose file
    docker-compose.yml
    networks:
      redpanda_network:
        driver: bridge
    volumes:
      redpanda-0: null
      redpanda-1: null
      redpanda-2: null
    services:
      redpanda-0:
        command:
          - redpanda
          - start
          - --kafka-addr internal://0.0.0.0:9092,external://0.0.0.0:19092
          # Address the broker advertises to clients that connect to the Kafka API.
          # Use the internal addresses to connect to the Redpanda brokers'
          # from inside the same Docker network.
          # Use the external addresses to connect to the Redpanda brokers'
          # from outside the Docker network.
          - --advertise-kafka-addr internal://redpanda-0:9092,external://localhost:19092
          - --pandaproxy-addr internal://0.0.0.0:8082,external://0.0.0.0:18082
          # Address the broker advertises to clients that connect to the HTTP Proxy.
          - --advertise-pandaproxy-addr internal://redpanda-0:8082,external://localhost:18082
          - --schema-registry-addr internal://0.0.0.0:8081,external://0.0.0.0:18081
          # Redpanda brokers use the RPC API to communicate with each other internally.
          - --rpc-addr redpanda-0:33145
          - --advertise-rpc-addr redpanda-0:33145
          # Mode dev-container uses well-known configuration properties for development in containers.
          - --mode dev-container
          # Tells Seastar (the framework Redpanda uses under the hood) to use 1 core on the system.
          - --smp 1
          - --default-log-level=info
        image: docker.redpanda.com/redpandadata/redpanda:v24.2.8
        container_name: redpanda-0
        volumes:
          - redpanda-0:/var/lib/redpanda/data
        networks:
          - redpanda_network
        ports:
          - 18081:18081
          - 18082:18082
          - 19092:19092
          - 19644:9644
      redpanda-1:
        command:
          - redpanda
          - start
          - --kafka-addr internal://0.0.0.0:9092,external://0.0.0.0:29092
          - --advertise-kafka-addr internal://redpanda-1:9092,external://localhost:29092
          - --pandaproxy-addr internal://0.0.0.0:8082,external://0.0.0.0:28082
          - --advertise-pandaproxy-addr internal://redpanda-1:8082,external://localhost:28082
          - --schema-registry-addr internal://0.0.0.0:8081,external://0.0.0.0:28081
          - --rpc-addr redpanda-1:33145
          - --advertise-rpc-addr redpanda-1:33145
          - --mode dev-container
          - --smp 1
          - --default-log-level=info
          - --seeds redpanda-0:33145
        image: docker.redpanda.com/redpandadata/redpanda:v24.2.8
        container_name: redpanda-1
        volumes:
          - redpanda-1:/var/lib/redpanda/data
        networks:
          - redpanda_network
        ports:
          - 28081:28081
          - 28082:28082
          - 29092:29092
          - 29644:9644
        depends_on:
          - redpanda-0
      redpanda-2:
        command:
          - redpanda
          - start
          - --kafka-addr internal://0.0.0.0:9092,external://0.0.0.0:39092
          - --advertise-kafka-addr internal://redpanda-2:9092,external://localhost:39092
          - --pandaproxy-addr internal://0.0.0.0:8082,external://0.0.0.0:38082
          - --advertise-pandaproxy-addr internal://redpanda-2:8082,external://localhost:38082
          - --schema-registry-addr internal://0.0.0.0:8081,external://0.0.0.0:38081
          - --rpc-addr redpanda-2:33145
          - --advertise-rpc-addr redpanda-2:33145
          - --mode dev-container
          - --smp 1
          - --default-log-level=info
          - --seeds redpanda-0:33145
        image: docker.redpanda.com/redpandadata/redpanda:v24.2.8
        container_name: redpanda-2
        volumes:
          - redpanda-2:/var/lib/redpanda/data
        networks:
          - redpanda_network
        ports:
          - 38081:38081
          - 38082:38082
          - 39092:39092
          - 39644:9644
        depends_on:
          - redpanda-0
      console:
        container_name: redpanda-console
        image: docker.redpanda.com/redpandadata/console:v2.7.2
        networks:
          - redpanda_network
        entrypoint: /bin/sh
        command: -c 'echo "$$CONSOLE_CONFIG_FILE" > /tmp/config.yml; /app/console'
        environment:
          CONFIG_FILEPATH: /tmp/config.yml
          CONSOLE_CONFIG_FILE: |
            kafka:
              brokers: ["redpanda-0:9092"]
              schemaRegistry:
                enabled: true
                urls: ["http://redpanda-0:8081"]
            redpanda:
              adminApi:
                enabled: true
                urls: ["http://redpanda-0:9644"]
        ports:
          - 8080:8080
        depends_on:
          - redpanda-0
  2. Set the REDPANDA_VERSION environment variable to the version of Redpanda that you want to run. For all available versions, see the GitHub releases.

    For example:

    export REDPANDA_VERSION=24.2.8
  3. Set the REDPANDA_CONSOLE_VERSION environment variable to the version of Redpanda Console that you want to run. For all available versions, see the GitHub releases.

    For example:

    export REDPANDA_CONSOLE_VERSION=2.7.2
  4. Run the following in the directory where you saved the Docker Compose file:

    docker compose up -d
  5. Open Redpanda Console at localhost:8080.

Clean up

To shut down and delete the containers along with all your cluster data:

docker compose down -v