# 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 6.4 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: `truncate`, `sys-admin role`, `sindex-admin`, `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/2.5.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**
    
    (optional) Pull from the Google Container Registry if running in GCP:
    
    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, namespace, default indexes to create and much more. For a complete list of available config 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

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:

```plaintext
docker logs -f [<CONTAINER_NAME>]
```

After successfully completing the startup procedure, you are ready to start using AGS. See [Basic usage](https://aerospike.com/docs/graph/2.5.0/develop/query/basics) to get started on interacting with your graph data.

## 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:
    
    ```txt
    docker run -it aerospike/aerospike-tools asadm -h <HOSTNAME>
    ```
    
2.  Enable dynamic configuration changes with the following command at the `Admin>` prompt:
    
    ```txt
    enable
    ```
    
3.  Set your namespace’s `default-ttl` option to 0:
    
    ```txt
    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 environmental 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
```