Cratopus icon

🐳 Docker Deployment Guide

The Crate Community Edition (CE) is lightweight and performs exceptionally well when running inside a container. This guide will help you deploy and scale your Crate CE instance using Docker and Docker Compose.

Official Docker Image

The official Docker image for Crate CE is available on the GitLab Container Registry as registry.gitlab.com/cratecc/ce.

docker pull registry.gitlab.com/cratecc/ce:latest

Running with Docker Desktop

If you’re running Docker locally, follow these steps to get a basic setup running:

  1. Create your configuration directory:
    mkdir -p crate-config
    
  2. Add a configuration file: Create bc7e5f3a-8b1e-4b1a-9c1a-1a2b3c4d5e6f.yaml in the crate-config directory.
  3. Run the container:
    docker run -d \
      -p 9980:9980 \
      -v $(pwd)/crate-config:/etc/crate/config \
      --name crate-ce \
      registry.gitlab.com/cratecc/ce:latest
    

For more complex setups, Docker Compose is the recommended way to manage your containers.

Create a docker-compose.yml file:

version: '3.8'

services:
  gateway:
    image: registry.gitlab.com/cratecc/ce:latest
    ports:
      - "9980:9980"
    environment:
      - CONFIG_STORAGE_DIR=/etc/crate/config
      - TRAFFIC_LOG_FILE=true
    volumes:
      - ./config:/etc/crate/config
      - ./logs:/var/log/crate
    restart: always

  # Optional: Built-in Mirror Service for testing
  mirror:
    image: cratecc/mirror:latest
    ports:
      - "8080:8080"

To start your environment, run:

docker-compose up -d

Configuration Management

When running with Docker, it’s essential to manage your configuration files securely.

Persistent Volumes

Always mount your configuration directory as a persistent volume. This allows you to update your YAML files on the host machine and have the changes reflected immediately inside the container.

volumes:
  - ./config:/etc/crate/config

Environment Overrides

You can override any Crate CE setting using environment variables in your docker-compose.yml file:

  • CONFIG_STORAGE_DIR: Change the location where Crate searches for YAML files.
  • PORT: Choose a different port for the Gateway to listen on.
  • LOG_FILE: Enable or disable system logs to a file.

Scaling Crate CE

Since Crate CE uses in-memory state, each instance operates independently. This makes it incredibly easy to scale horizontally.

  1. Run multiple instances: Start multiple containers on different ports or different host machines.
  2. Configure a Load Balancer: Use a fleet of Crate CE instances behind a global load balancer (like AWS ELB, NGINX, or HAProxy) for high availability and increased throughput.

Next Steps