# Deploy Aerospike Graph Service with Docker

## Overview

This page describes how to run Aerospike Graph Service (AGS) using [Docker](https://www.docker.com/) and connect to an Aerospike database cluster.

## Prerequisites

-   An Aerospike [feature key file](https://aerospike.com/docs/database/manage/planning/feature-key) which has the `graph-service` key enabled. [Click here](https://aerospike.com/get-started-aerospike-graph/) to get a free 60 day trial key, or contact your Aerospike account manager.
    
-   A running [Aerospike Database](https://aerospike.com/download/) instance, version 7.0 or later. You can either connect to an existing cluster, or start one using Docker. See [Install with Docker](https://aerospike.com/docs/database/install/docker/) to set up an Aerospike Database with Docker.
    
    -   Verify the IP address of your Aerospike database. If you are running Aerospike in a Docker container locally, you can get the IP address with the following command:
    
    Terminal window
    
    ```bash
    docker inspect -f  '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' AEROSPIKE_CONTAINER_ID
    ```
    

-   Replace `AEROSPIKE_CONTAINER_ID` with the Docker container ID of your Aerospike container.

### Aerospike database environment requirements

-   If [access control](https://aerospike.com/docs/database/manage/security/rbac/) is enabled on the Aerospike database, AGS must have the following privileges as a database user: `sys-admin` and `read-write`.
    
-   The namespace which AGS uses on your Aerospike database server must not have the configuration option [`default-ttl`](https://aerospike.com/docs/database/reference/config#namespace__default-ttl) set to anything but 0. See the [instructions](#ttl-on-the-aerospike-namespace) for setting this option after the server has started.
    

## Run AGS with Docker

::: note
There are two versions of the AGS Docker image available, standard and slim. The [standard version](https://hub.docker.com/r/aerospike/aerospike-graph-service/tags) includes the [Standalone Bulk Loader](https://aerospike.com/docs/graph/3.0.0/develop/data-loading/standalone). The [slim version](https://hub.docker.com/r/aerospike/aerospike-graph-service/tags), a lightweight alternative to the standard image, offers a smaller footprint for faster scale-out and enhanced operational efficiency.
:::

1.  Pull the AGS Docker image.
    
    Terminal window
    
    ```bash
    docker pull aerospike/aerospike-graph-service
    ```
    
    Or, if running in GCP, pull from the Google Container Registry:
    
    Terminal window
    
    ```bash
    docker pull gcr.io/aerospike-prod/aerospike-graph-service
    ```
    
2.  Run the AGS Docker container.
    
    Terminal window
    
    ```bash
    docker run -p8182:8182 -e [OPTIONS] aerospike/aerospike-graph-service
    ```
    
    The options you pass to your Docker command specify which Aerospike database cluster to connect to, which namespace, which default indexes to create, and more. For a complete list of available configuration options, see [Configuration options](https://aerospike.com/docs/graph/reference/config).
    
    You can also specify configuration options with a [properties file](#use-a-properties-file) (recommended).
    
    The following example Docker command starts an AGS instance:
    
    Terminal window
    
    ```bash
    docker run -d -p8182:8182 -e aerospike.client.namespace="test" \
    
    -e aerospike.client.host="HOSTNAME:PORT" \
    
    aerospike/aerospike-graph-service
    ```
    
    Replace `HOSTNAME:PORT` with the hostname and port of your Aerospike database server.
    

## Server output

AGS writes logs to `stdout`. When running in Docker, these logs are captured by Docker and available through `docker logs`. For a complete list of command options, see the [Docker documentation](https://docs.docker.com/reference/cli/docker/container/logs/).

If you start your AGS Docker container with the `-d` option, the server output does not appear in your terminal window. You can find it with the `docker logs` command:

Terminal window

```bash
docker logs -f [CONTAINER_NAME]
```

After successfully completing the startup procedure, you are ready to start using AGS. See [Graph Quickstart](https://aerospike.com/docs/graph/quick-start) to get started on interacting with your graph data.

### Configure AGS logging

Use Docker’s log driver options to rotate and cap AGS logs. The example below uses the `json-file` log driver with rotation settings. Adjust sizes and file counts for your environment.

Terminal window

```bash
docker run \

  --log-driver=json-file \

  --log-opt max-size=10m \

  --log-opt max-file=5 \

  -p8182:8182 \

  -e aerospike.client.namespace="test" \

  -e aerospike.client.host="HOSTNAME:PORT" \

  aerospike/aerospike-graph-service
```

## TTL on the Aerospike namespace

The Aerospike database namespace which AGS uses must not have the configuration option [`default-ttl`](https://aerospike.com/docs/database/reference/config#namespace__default-ttl) set to anything but 0. If you see an AGS startup error referring to the `default-ttl` configuration option, use the following procedure to set it to 0:

1.  Start the Aerospike Tools Docker image:
    
    Terminal window
    
    ```bash
    docker run -it aerospike/aerospike-tools asadm -h HOSTNAME
    ```
    
2.  Enable dynamic configuration changes with the following command at the `Admin>` prompt:
    
    Terminal window
    
    ```bash
    enable
    ```
    
3.  Set your namespace’s `default-ttl` option to 0:
    
    Terminal window
    
    ```bash
    manage config namespace NAMESPACE_NAME param default-ttl to 0
    ```
    

## Configuration options

This section describes how to specify AGS [configuration options](https://aerospike.com/docs/graph/reference/config) at startup using a Docker flag or a properties file.

#### Specify AGS configurations using environment variables

Use the `-e` flag, passed with the `docker run` command, to set an environment variable in the container. In this example, the flag is used to set `aerospike.client.namespace` and `aerospike.client.host`.

Terminal window

```bash
docker run -p8182:8182 -e aerospike.client.namespace="test" \

-e aerospike.client.host="HOSTNAME:PORT" \

aerospike/aerospike-graph-service
```

#### Use a properties file

The following example illustrates a properties file that specifies configuration options and their values.

```plaintext
aerospike.client.namespace=test

aerospike.client.host=aerospike-devel-cluster-host1:3000, aerospike-devel-cluster-host2:3000

aerospike.graph.index.vertex.properties=property1, property2

aerospike.graph.index.vertex.label.enabled=true
```

To use a properties file when running the AGS Docker image, use the `-v` flag to create a volume bind. In the following example, the full local path to the properties file is `/home/graph-user/graph/conf/aerospike-graph.properties`. The filepath after the `:`, `/opt/aerospike-graph/aerospike-graph.properties`, is the corresponding properties file in the AGS Docker container.

::: note
The local properties file may be in any location, but the bound volume on the Docker image must be at `/opt/aerospike-graph/aerospike-graph.properties`.
:::

Terminal window

```bash
docker run -p 8182:8182 \

-v /home/graph-user/graph/conf/aerospike-graph.properties:/opt/aerospike-graph/aerospike-graph.properties \

aerospike/aerospike-graph-service
```