Docs / Run

Docker

Since v0.4.0, Ghoti ships as a small container image for linux/amd64 and linux/arm64. Pull it, mount your config.yaml, and publish port 9090.

Get the image#

The image is ghcr.io/dankomiocevic/ghoti. It is public, so pulling it needs no login:

$ docker pull ghcr.io/dankomiocevic/ghoti

Docker picks the variant for your machine's architecture. Every release pushes these tags:

TagPoints to
<version>, for example 0.4.0That release. The tag has no leading v, like the release archives.
latestThe newest release. Pre-releases don't move it.

Pin a version in anything you deploy, so a new release doesn't reach your servers on its own:

$ docker pull ghcr.io/dankomiocevic/ghoti:0.4.0
$ docker run --rm ghcr.io/dankomiocevic/ghoti:0.4.0 version

The image is built from the same binaries as the release archives, on a distroless base: it holds the ghoti binary, a default configuration and nothing else.

Build it locally#

To try changes that aren't released yet, build the image from a clone of the repository. With Go and Docker installed, make docker builds the image for your architecture and tags it ghoti:dev:

$ git clone https://github.com/dankomiocevic/ghoti.git && cd ghoti
$ make docker
$ docker run --rm -p 9090:9090 ghoti:dev

Set DOCKER_ARCH to build for another architecture and DOCKER_IMAGE to change the tag, for example make docker DOCKER_ARCH=arm64 DOCKER_IMAGE=ghoti:arm64. Use ghoti:dev wherever this page says ghcr.io/dankomiocevic/ghoti.

Run it#

The image comes with a default configuration, so it answers right away:

$ docker run --rm -p 9090:9090 ghcr.io/dankomiocevic/ghoti
{"time":"2026-11-28T22:33:33.344Z","level":"INFO","msg":"Starting server..."}

The default configuration has the slots of the quick start, plus a rate limiter and a broadcast channel:

SlotKind
000simple_memory
001atomic
002token_bucket, 2 tokens refilled 2 per minute
003broadcast

From another terminal, nc localhost 9090 talks to it as in the quick start:

> w000hello
< v000hello
> r001
< v0011

Stop it with Ctrl+C, or docker stop when it runs in the background. Either way the server shuts down cleanly.

Add your configuration#

The default configuration is only for trying Ghoti out. Your slots, users, metrics and cluster settings go in your own config.yaml, which you mount into the container. Write it as you would for the binary, for example:

log:
  level: info

slot_000:
  kind: token_bucket
  bucket_size: 100
  refresh_rate: 100
  period: second

slot_001:
  kind: timeout_memory
  timeout: 30

Leave addr out: the image already sets it to listen on all interfaces of the container (see Environment variables).

Mount the file over the default#

The server reads /etc/ghoti/config.yaml. Mount your file at that path and it replaces the default one completely, so only your slots exist:

$ docker run --rm -p 9090:9090 \
    -v "$(pwd)/config.yaml:/etc/ghoti/config.yaml:ro" \
    ghcr.io/dankomiocevic/ghoti

Docker needs an absolute path on the host side, hence $(pwd). The :ro suffix mounts it read-only: Ghoti never writes to it.

Or mount a directory and use --config#

To keep the file under another name or path, mount its directory and point --config at it. Arguments after the image name replace the default command, so start them with run:

$ docker run --rm -p 9090:9090 \
    -v "$(pwd)/deploy:/config:ro" \
    ghcr.io/dankomiocevic/ghoti run --config /config/ghoti.yaml

With --config, the default locations are not searched, so a wrong path stops the server with exit status 1 instead of starting with the built-in slots.

The file must be readable by everyone#

The server runs as an unprivileged user (UID 65532), not as root and not as your user. A file only you can read, such as one with mode 600, stops it at start-up:

ERROR Error loading config error="failed to load server config: open /etc/ghoti/config.yaml: permission denied"

Make the file world-readable with chmod 644 config.yaml. Keep secrets out of it, and pass them as environment variables instead.

Applying a change#

The configuration is read once, at start-up. After editing the file, restart the container with docker restart. A restart empties every slot, like any restart of Ghoti. Slot definitions are not validated, so read each slot once after the restart: an invalid one answers e<slot>005 (see What is validated at startup).

Environment variables#

The image sets two variables, because the server defaults don't suit a container:

VariableValue in the imageWhy
GHOTI_ADDR:9090The server default, localhost:9090, can't be reached from outside the container.
GHOTI_LOG_FORMATjsonContainer logs are usually collected and parsed. Set it to text to read them by hand.

An environment variable overrides the file, so these two win over addr and log.format in your config.yaml. Change them with -e, and set any other GHOTI_* variable the same way:

$ docker run --rm -p 9090:9090 \
    -e GHOTI_LOG_FORMAT=text -e GHOTI_LOG_LEVEL=debug \
    ghcr.io/dankomiocevic/ghoti

Environment variables can only override keys, not add sections:

Other ports#

Only port 9090 is set up by the image. The metrics endpoint and the cluster manager listen where your configuration says, and they also have to bind all interfaces of the container to be reachable, for example:

metrics:
  enabled: true
  addr: ":9100"

Then publish the port too, with -p 9100:9100. The examples elsewhere in these docs use 127.0.0.1, which inside a container means the container itself.

Docker Compose#

A compose.yaml next to your config.yaml:

services:
  ghoti:
    image: ghcr.io/dankomiocevic/ghoti:0.4.0
    ports:
      - "9090:9090"
    volumes:
      - ./config.yaml:/etc/ghoti/config.yaml:ro
    environment:
      GHOTI_LOG_LEVEL: info
    restart: unless-stopped

Start it with docker compose up -d. Compose accepts the relative path, and other services in the same file reach the server at ghoti:9090.

Kubernetes#

Put the configuration in a ConfigMap and mount its config.yaml key over the default file with subPath. Files projected from a ConfigMap are world-readable by default, so the permission note above doesn't apply:

apiVersion: v1
kind: ConfigMap
metadata:
  name: ghoti
data:
  config.yaml: |
    slot_000:
      kind: token_bucket
      bucket_size: 100
      refresh_rate: 100
      period: second
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ghoti
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels: {app: ghoti}
  template:
    metadata:
      labels: {app: ghoti}
    spec:
      containers:
        - name: ghoti
          image: ghcr.io/dankomiocevic/ghoti:0.4.0
          ports:
            - containerPort: 9090
          volumeMounts:
            - name: config
              mountPath: /etc/ghoti/config.yaml
              subPath: config.yaml
              readOnly: true
          readinessProbe:
            tcpSocket: {port: 9090}
          livenessProbe:
            tcpSocket: {port: 9090}
      volumes:
        - name: config
          configMap:
            name: ghoti

Good to know#

Found something out of date? Open an issue.