Docker Compose

Create a file called docker-compose.yml in a new directory with the following content:

version: "3.4"

    # Important for this to be static and unique
    hostname: gravity1
    restart: unless-stopped
    network_mode: host
      - data:/data
    # environment:
    #   LOG_LEVEL: info
    # The default log level of info logs DHCP and DNS queries, so ensure
    # the logs aren't filling up the disk
      driver: json-file
        max-size: "10m"
        max-file: "3"

    driver: local

Run docker compose up -d to start gravity.

First time use

A default admin user is created on the first startup. You can find the credentials printed to stdout (accessible with docker compose logs).

You can reach Gravity by going to http://<server IP or hostname>:8008 in your browser.


The following environment variables can be set.

  • BOOTSTRAP_ROLES: Configure which roles this instance should bootstrap. Defaults to dns;dhcp;api;etcd;discovery;backup;monitoring;tsdb.
  • LOG_LEVEL: Log level. Defaults to info.
  • DATA_PATH: Path to store etcd data. Defaults to ./data.
  • INSTANCE_IDENTIFIER: Unique identifier of an instance, should ideally not change. Defaults to the detected hostname. When running in Docker, this is configured via the hostname attribute.
  • INSTANCE_IP: This instance’s reachable IP. When running in Docker and not using network_mode: host, this should be the host’s IP.
  • LISTEN_ONLY: Enable listen-only mode. In listen-only mode, Gravity will not reply to any DHCP packets and will not run discovery.
  • DEBUG: Enable debug mode. This should not be set manually in most cases and is only intended for development environments.
  • INSTANCE_LISTEN: By default the instance will listen on INSTANCE_IP, but this option will override that. Set to when using Docker.
  • ADMIN_PASSWORD: Optionally set a default password for the admin user. If unset, a random password will be generated as described above.
  • ADMIN_TOKEN: Optionally set a token to be created on first start. If unset, no token will be created.
  • SENTRY_ENABLED: Enable Sentry error reporting and tracing. Defaults to false.
  • SENTRY_DSN: Configure a custom Sentry DSN.
  • ETCD_PREFIX: Global etcd prefix. Defaults to /gravity.
  • ETCD_PEER_PORT: Port used for etcd peer traffic. Defaults to 2380. This may need to be changed when running in Kubernetes.
  • ETCD_ENDPOINT: etcd Client endpoint. Defaults to localhost:2379 when using embedded etcd.
  • ETCD_JOIN_CLUSTER: Set to a join cluster token to join the node to a cluster. See Clustering.
Changing Environment Variables

Gravity is designed so that you ideally don’t have to explicitly define environment variables, but if necessary, environment variables can be added or changed by modifying the environment: options in the Docker Compose file.


      BOOTSTRAP_ROLES: dns;api;etcd;discovery;monitoring;tsdb
      INSTANCE_IDENTIFIER: my-gravity-server