Skip to main content

Install G8 with Docker Compose and open the console in an afternoon

A compose file with two services, the variables the server needs, the start it refuses without the secrets key, the setup token in the log, the first sign-in.

By Efsun Balcı Getting started

What you will have at the end

The G8 console and API running on one Linux host, next to a gateway cluster you already run, with its own PostgreSQL in a volume, signed in as the first administrator you created with the setup token from the server’s log. The secrets key that seals every stored password and admin key is one you generated and keep. The gateway cluster appears as the first Environment, reachable, with its Routes counted on the Overview.

Two things to know before you start. This is the trial layout: plain HTTP on one host, for a laptop or a lab machine. For production, the Helm chart on OpenShift, OKD or Kubernetes, or Linux virtual machines; the layouts are in the product documentation and on Deployment. And G8 is the second half of an installation: it manages a gateway cluster that is already running, and does not install one. The engine’s own guide, also in the documentation, puts that cluster on a Docker host with Compose; this article was walked on a host set up that way.

Prerequisites

  • A Linux host with Docker and the Compose plugin. The one here is Ubuntu 24.04 with 4 vCPU and 8 GB, and the gateway cluster of the engine guide already on it, in a Docker network named g8gw.
  • The gateway’s Admin API address as the G8 container will reach it: the engine container’s name as docker ps shows it, on port 9180, over the network both will share. And the admin key, which the engine guide put in the engine’s config.yaml under admin_key, or in the variable that line references.
  • The two images, pulled from the registry you were given: the product image and PostgreSQL 18. On this host they are 55 MB and 650 MB.
  • A port for the console. 8080 here.

The compose file

Two services: the database, and the server that serves the console and the API. The directory belongs to root on most hosts, so make it yours first, then put the file in /opt/g8/compose.yaml:

sudo mkdir -p /opt/g8 && sudo chown "$USER" /opt/g8
services:
  postgres:
    image: ${G8_POSTGRES_IMAGE:?set G8_POSTGRES_IMAGE in .env}
    restart: unless-stopped
    environment:
      POSTGRES_USER: g8
      POSTGRES_PASSWORD: ${G8_PG_PASSWORD:?set G8_PG_PASSWORD in .env}
      POSTGRES_DB: g8
      PGDATA: /var/lib/postgresql/data
    volumes:
      - g8-postgres:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -h 127.0.0.1 -U g8 -d g8"]
      interval: 2s
      timeout: 2s
      retries: 30

  g8:
    image: ${G8_IMAGE:?set G8_IMAGE in .env}
    restart: unless-stopped
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      G8_LISTEN_ADDR: ":8080"
      G8_PG_DSN: postgres://g8:${G8_PG_PASSWORD}@postgres:5432/g8?sslmode=disable
      G8_ENVIRONMENT: ${G8_ENVIRONMENT:?set G8_ENVIRONMENT in .env}
      G8_ENGINE_ADMIN_URL: ${G8_ENGINE_ADMIN_URL:?set G8_ENGINE_ADMIN_URL in .env}
      G8_ENGINE_ADMIN_KEY: ${G8_ENGINE_ADMIN_KEY:?set G8_ENGINE_ADMIN_KEY in .env}
      G8_SECRETS_KEY: ${G8_SECRETS_KEY:-}
    ports:
      - "8080:8080"
    networks:
      - default
      - g8gw

networks:
  g8gw:
    external: true

volumes:
  g8-postgres:

The g8 service joins two networks: its own, where PostgreSQL is, and the gateway’s, so that the engine container’s name resolves. This file publishes one port, the console’s; the Admin API is reached over the shared network, and whether the gateway’s own compose file also publishes it on the host is that file’s choice, not this one’s.

The variables

Every value the server reads comes from /opt/g8/.env, which only you can read:

G8_IMAGE=<your registry>/g8/g8:v0.9.14
G8_POSTGRES_IMAGE=<your registry>/infra/postgres:18.6
G8_PG_PASSWORD=<a password for the database user g8, letters and digits only>
G8_ENVIRONMENT=dev
G8_ENGINE_ADMIN_URL=http://<engine container>:9180
G8_ENGINE_ADMIN_KEY=<the admin key of the gateway's Admin API>
chmod 600 /opt/g8/.env

What each one does, from the server’s own configuration page in the documentation:

  • G8_PG_DSN, built in the compose file from the password: the PostgreSQL connection. The password is written into a URL there, which is why it is letters and digits only; a @, : or / in it would break the address. The server applies its schema on this database at every start.
  • G8_ENVIRONMENT, G8_ENGINE_ADMIN_URL, G8_ENGINE_ADMIN_KEY: the first Environment, read at the first start only, when no Environment exists yet. From then on the Environments table is the source of truth and the console edits it; the server still refuses to start without the address, so keep it set. The key is sealed before it is stored.
  • G8_SECRETS_KEY: the key that seals every stored secret, 64 hexadecimal characters. It is deliberately missing from the file above.
  • G8_LISTEN_ADDR: the port, for the console and the API alike.

Everything else, sessions, lockout, rate limits, audit retention, keeps its default, and the TLS pair G8_TLS_CERT_FILE and G8_TLS_KEY_FILE stays unset because this is a trial on one host. In front of users, put a certificate on the server or a reverse proxy in front of it, and name the proxy in G8_TRUSTED_PROXIES so that sign-ins count against the client’s address and not the proxy’s.

Start, and watch it refuse

cd /opt/g8
docker compose pull
docker compose up -d
docker compose ps
docker compose logs g8

PostgreSQL comes up healthy; the server does not stay up. Its log says why, once per restart:

{"level":"ERROR","msg":"server exited","error":"missing required environment: [G8_SECRETS_KEY]"}

This is the line a security reviewer asks for: the server will not run without the key that seals its secrets, so nothing is ever stored unsealed by accident. Generate the key, append it to the file, and put a copy in the password manager or secret store your team already uses, because a key that lives only on this host dies with it:

echo "G8_SECRETS_KEY=$(openssl rand -hex 32)" >> /opt/g8/.env
docker compose up -d
docker compose logs g8

Now the log tells the story of a first start. Between them are three housekeeping lines about pruning old audit rows, records and alert history, which say zero on a fresh install; the four that matter:

{"level":"INFO","msg":"schema ready","version_from":0,"version_to":16,...}
{"level":"INFO","msg":"environment seeded from G8_ENVIRONMENT and G8_ENGINE_ADMIN_URL; the table is the source of truth from now on","environment":"dev"}
{"level":"WARN","msg":"g8 has no users yet: open the console and create the first administrator with this setup token; every replica of this install prints the same one","setup_token":"..."}
{"level":"INFO","msg":"listening","addr":"[::]:8080","tls":false}

The schema was applied, the first Environment was created from the three variables, and there is no user yet, so the server printed a setup token. Do the next step now, on a host nobody else can reach yet: while no user exists, anyone who can open port 8080 and read that log line can create the first administrator. Three addresses answer from outside the container as soon as it listens: /healthz with {"status":"ok"}, /readyz with {"status":"ready"} once the database and the secrets key check out, and /version with the release and the commit it was built from.

Create the first administrator

Open http://<host>:8080 in a browser. Because no user exists, the console shows one page: the setup token from the log, a display name, a username, an optional email and a password of at least twelve characters.

The page Create the first administrator: the sentence that g8 has no users yet and asks for the setup token from the server log, then the fields Setup token, Display name, Username, Email and Password, and the button Create administrator One token, one account. The token is printed only while there is no user; once this form is submitted it is gone.

Create administrator signs you in; the token is consumed by that one request. A script that does this step through the API instead of the console sends an Origin header naming the server, as the console does. Both refusals, from the lab install:

### the same setup token posted a second time
HTTP/1.1 410 Gone
{"error":"gone"}
### a setup request without an Origin header
HTTP/1.1 403 Forbidden
{"error":"forbidden","reason":"cross_site_request"}

The first thing the console shows is the Environment the server seeded, with the engine card already filled from the Admin API: the engine’s version and that this release was verified against it, the Admin API reachable, and what the cluster holds. The lab’s cluster had nine Routes before G8 ever saw it, and the card counts them, because G8 manages what is already running.

The Overview of the Environment dev right after the first sign-in: the Engine card with the engine's version and a Verified pill, Admin API reachable in 4 ms, 109 plugins available, 9 Routes, 3 Services, 3 Upstreams, 3 Consumers, 2 Global rules; the Environment card with the engine admin URL pointing at the gateway container on port 9180 and the server version v0.9.14; Analytics and Traffic Explorer marked Not connected in the navigation The engine’s name and version are on this card, and the server’s own version at the bottom of the navigation. Analytics and Traffic Explorer say Not connected: no Prometheus and no log store yet.

The navigation’s last entry, Help & about, is not available in this release; the version is the line under the navigation, and the engine is named on the Overview card and in the Engine section of the Environment form.

The platform audit log holds three records: bootstrap.admin_created, the administrator created with the setup token; assignment.granted, the Platform administrator role on every Environment; and auth.login_succeeded, the sign-in. A second person who reads the token in the log later gets the 410 above.

What is on disk

  • /opt/g8/compose.yaml and /opt/g8/.env: the whole installation. Back up .env; without G8_SECRETS_KEY the stored admin key and every password are unreadable to a new server.
  • The volume, which Compose names g8_g8-postgres after the project directory: every Environment, user, role and audit record. The engine’s configuration is not in it; that lives in the gateway cluster’s own store, which G8 reads and writes through the Admin API.
  • The two images. Upgrading is a new G8_IMAGE and docker compose up -d; the server applies the schema changes at start.

The Environments page of the fresh install: one Environment, dev, Reachable with the engine version in 4 ms, no connections, no protection, and the Add environment button One install, one engine cluster per row. The next article adds a second one with the connection test.

What to do next

Written by
Efsun Balcı
Engineering intern, G8
Was this helpful?
Next step

See G8 in a demo

We’ll show you the console with APIs and AI traffic like yours, and answer the questions these articles leave open.

  1. 01Demo
  2. 02Proof of conceptOn Docker for a quick start, or on the infrastructure you plan to run G8 on.
  3. 03LicenseWe prepare a quote for your edition and nodes, and you receive a signed license file.