How to Connect Containers Using the SnapShooter Agent

SnapShooter is a cloud backup and recovery solution. Use SnapShooter to back up servers, volumes, databases, and applications from DigitalOcean and other cloud providers.

The SnapShooter Agent allows SnapShooter to communicate with private resources that are behind a NAT gateway or firewall. Using the agent also eliminates the need to configure firewalls, incoming connection rules, or IP allowlists.

The agent works by opening a persistent communication channel from the target resource back to the SnapShooter network. The resulting backups are identical to backups taken with an SSH-based connection.

You can run the SnapShooter Agent in a Docker container to access Docker volumes and other containerized resources.

Supported Environments

The SnapShooter Agent supports the following architectures:

  • x86 (386)
  • x86 64-bit (amd64)
  • ARM (arm)
  • ARM 64-bit (arm64)

The agent runs on the following operating systems:

  • Linux (linux)
  • OpenBSD (openbsd)
  • FreeBSD (freebsd)
  • NetBSD (netbsd)
  • macOS (darwin)

Add an Agent Server

The SnapShooter Agent needs an access token to connect to the service. To set up a new agent and retrieve your access token and download URL, go to the Add Agent Server Manually page.

Name your server and click Generate Agent Server Token.

Select the target operating system and architecture for your container. This generates the correct download URL for the agent software. Save the URL and the token for the next step.

Create the Image

The following Dockerfile uses an Ubuntu base image to set up a minimal containerized SnapShooter agent.

FROM ubuntu:latest
WORKDIR /opt/snapshooter
# Install required packages
RUN apt-get update && apt-get install -y curl gzip tar
# Download the agent binary, unzip it, and set execute permissions
RUN curl -sSL "<your_download_URL_here>" -o agent.gz \
    && gzip -d agent.gz \
    && chmod +x agent

# Run the agent
CMD ["/opt/snapshooter/agent"]

This Dockerfile installs a few utilities, then uses them to download and decompress the agent software. Replace <your_download_URL_here> with the URL you copied in the previous step.

If your backup recipe requires specific command line utilities to function, add the relevant packages to the end of the apt-get line in the Dockerfile. For instance, to back up PostgreSQL databases, you need the pg_dump utility, which is available in the postgresql-client package on Ubuntu.

Save the file as Dockerfile, then run the build command from the same directory as the Dockerfile.

docker build -t snapshooter .

This builds an image named snapshooter. Use the docker images command to verify.

REPOSITORY                                       TAG         IMAGE ID       CREATED         SIZE
snapshooter                                      latest      adcd6dcc5f0d   8 seconds ago   131MB

The output lists a snapshooter image. In the next step we use this image to run a containerized SnapShooter agent.

Run the Container

To run the agent, you first need to set the SNAPSHOOTER_AGENT_TOKEN environment variable. One way to specify this variable is to create a .env file in same directory as the Dockerfile. The file format is a key=value pair per line:


Paste in the token you created in the first step. Save this file in the same directory as your Dockerfile. If you’re checking the Dockerfile into source control, add .env to your .gitignore file to avoid leaking secret tokens.

Now use docker run to create and run a container from the snapshooter image:

docker run -d --env-file .env snapshooter

The -d flag puts the container in the background to run detached until you stop it, and --env-file imports all the environment variables from the specified file. snapshooter is the name of the image to run.

Run docker ps to verify the container is running:

CONTAINER ID   IMAGE        COMMAND                  CREATED       STATUS             PORTS     NAMES
23ecbe823dbf   snapshooter  "/opt/snapshooter/ag…"   2 hours ago   Up About an hour             goofy_mendel

The agent server should now show as connected in the SnapShooter control panel, and you can begin configuring your backup jobs.

Run the Container Using Docker Compose

The following YAML builds and runs the SnapShooter agent Dockerfile using Docker Compose. If you haven’t already, create a .env file with your access token in the same directory as your compose.yml and Dockerfile files by following the instructions in the previous step.

        build: .

This builds the Dockerfile in the current directory, then passes the SNAPSHOOTER_AGENT_TOKEN variable from the .env file through to the container’s environment.

Docker Compose automatically loads variables from files named .env. If you name your file something other than .env, use the env_file attribute to specify the file name.

Run the container with docker compose:

docker compose up -d

The command prints confirmation that the container has been created and started.

[+] Running 1/1
 ✔ Container example-snapshooter-1  Started 

Verify that the agent is connected in the SnapShooter control panel. You may now configure your backup jobs.

An Alternate Alpine-based Image

To build an Alpine-based SnapShooter agent container, you need to install bash along with curl, gzip, and tar:

FROM alpine:latest
WORKDIR /opt/snapshooter
# Install required packages
RUN apk add --no-cache bash curl gzip tar
# Download the agent binary, unzip it, and set execute permissions
RUN curl -sSL "<your_download_URL_here>" -o agent.gz \
    && gzip -d agent.gz \
    && chmod +x agent

# Run the agent
CMD ["/opt/snapshooter/agent"]

Replace <your_download_URL_here> with the URL you saved from the first step.

The final Alpine-based image has a size under 30 MB. The image using Ubuntu has a size of approximately 120 MB.