# Docker

Run kogut as a single container with its data in a volume.

The image supports `linux/amd64` and `linux/arm64`. For HTTPS, use [Caddy](https://docs.kogut.dev/installation/caddy/) or
[Tailscale](https://docs.kogut.dev/installation/tailscale/).

## Start the container

```sh
docker run -d --name kogut \
  -p 8484:8484 \
  -v kogut-data:/data \
  -e KOGUT_URL=http://localhost:8484 \
  --restart unless-stopped \
  --health-cmd "/usr/local/bin/kogut healthcheck" --health-interval 30s \
  ghcr.io/piotrkowski/kogut:0.1
```

For remote access, replace `http://localhost:8484` with the exact URL you open. Open it
and create your account with the setup token from the log
([First run](https://docs.kogut.dev/getting-started/first-run/)):

```sh
docker logs kogut 2>&1 | grep setup_token
```

[Upgrading](https://docs.kogut.dev/installation/upgrading/) lists the image tags.

## Keep data on the host

To keep `/data` in a host directory instead of the volume, make it writable by the
image's user, UID 65532:

```sh
sudo mkdir -p /srv/kogut
sudo chown 65532:65532 /srv/kogut
```

Replace `-v kogut-data:/data` with `-v /srv/kogut:/data` in the start command.

## Configuration

Set `KOGUT_URL` to the URL people and agents use. See
[Environment variables](https://docs.kogut.dev/reference/environment-variables/) for the rest.

To keep `kogut.toml` on the host, create `./config/kogut.toml` and add to `docker run`:

```sh
-v ./config:/etc/kogut:ro \
-e KOGUT_CONFIG=/etc/kogut/kogut.toml \
-e TELEGRAM_BOT_TOKEN
```

Write the secret as `${TELEGRAM_BOT_TOKEN}` in `kogut.toml` and export it before starting
the container. Mount the directory, not the file, or editors that replace files leave the
container reading an old copy. See [`kogut.toml`](https://docs.kogut.dev/reference/configuration/).

## Inspect the container

Use `docker logs kogut` for logs. The distroless image runs as a non-root user and has
no shell. It has no built-in `HEALTHCHECK`; the start command above adds one. In a
Compose service:

```yaml
healthcheck:
  test: ["CMD", "/usr/local/bin/kogut", "healthcheck"]
  interval: 30s
```

The [Docker Compose setup](https://docs.kogut.dev/installation/docker-compose/) includes it. See
[`kogut healthcheck`](https://docs.kogut.dev/reference/cli/#kogut-healthcheck) for its exit codes.

To monitor the host and its containers, see [Agent in Docker](https://docs.kogut.dev/agent/docker/), or
[Monitor the same host](https://docs.kogut.dev/installation/docker-compose/#monitor-the-same-host) to do it without a second
container.
