Skip to main content
All CollectionsStoreHivenet cloud
How can I connect my Synology NAS to Hivenet?
How can I connect my Synology NAS to Hivenet?

Learn to use your Synology NAS as a Hivenet node with Docker. Follow simple steps to get up and running quickly.

Thanasis Karavasilis avatar
Written by Thanasis Karavasilis
Updated over a month ago

What is Docker, and why use it?

Docker is a platform that enables packaging applications and their dependencies into containers. It allows your NAS to connect to Hivenet safely and efficiently. Here's what Docker brings to the table:

  • Isolation: Keeps your Hivenet node safe from other software on your NAS.

  • Portability: Move your Hivenet node to other systems without any fuss.

  • Scalability: Easily adjust how much you want to contribute to Hivenet.

  • Version Control: Ensure you always use the safest and latest hive-node software.

Ready? Let's dive in!


What you'll need

Before we begin, make sure you have:

  • A Synology NAS with DSM 7.1 or newer.

  • A Hivenet account. If you don't have one yet, sign up here.

Setting up your Synology NAS

Step 1: Prepare local files

  1. Configuration Files: On your computer, create a folder named machine-id. Inside, you'll need a unique 32-character code. You can generate one using this website (remember to disable hyphens).

Here's an example code (but please create your own!): 76c4bb0a2d114d7d8d48d8f076e0e6df

Step 2: Transfer files to the NAS

  1. Open File Station on your NAS and create a folder named docker.

  2. Inside docker, make two subfolders: .hive and script-logs.

  3. Upload the machine-id file you created earlier into the .hive folder.

screenshot of a Synology NAS on the docker page

Step 3: Set permissions

  1. Click on Properties for the .hive folder.

  2. Go to the Permissions tab and click Create.

  3. For the “Everyone” user, set "Administration," "Read," and "Write" permissions.

  4. Please make sure it's applied to the folder, sub-folders, and files, then save.

Screenshot of the permission page of a Synology NAS

Step 4: Install Docker and launch the Hivenet container

  1. Navigate to the Package Center and install Container Manager (or Docker if you use an older version of DSM).

  2. Create a “Hivenet container” task in Control Panel -> Task Scheduler.

    Screenshot from the interface of a Synology NAS
  3. Set the task to check for Hivenet agent updates daily.

    Screenshot from the interface of a Synology NAS
  4. Paste the provided Bash script into the "User-defined script" field.

The script manages the container, updates, and contributions! Change the script according to your needs by adjusting the following elements:

  1. the location of the Hivenet data: update /volume1/hiveNet with the relevant location on your NAS

  2. the amount of space you want to contribute: update contribute 5 the number of GB

#!/bin/bash 

IMAGE_NAME="hivecomputing/hive-disk:latest" CONTAINER_NAME="hivecomputing-hive-disk1" RUN_COMMAND="docker run --name=$CONTAINER_NAME -v /volume1/docker/.hive/machine-id:/etc/machine-id -v /volume1/docker/.hive:/home/hive/.hive -d --network host $IMAGE_NAME hive-agent contribute 5"

# Function to get image id of a Docker image
function get_image_digest {
local image=$1
docker image inspect --format="" "$image" 2>/dev/null
}

# Function to get container id of a Docker container
function get_container_id {
local container=$1
docker inspect --format="" "$container" 2>/dev/null
}

# Function to get image digest of a Docker container
function get_container_image_digest {
local container=$1
docker inspect --format="" "$container" 2>/dev/null
}

# Function to get container state
function get_container_state {
local container=$1
docker inspect --format="" "$container" 2>/dev/null
}

# Function to get image ID from image digest
function get_image_id_from_digest {
local digest=$1
docker images --digests --no-trunc | grep "$digest" | awk '{print $3}' 2>/dev/null
}

echo "Checking for new image..."
docker pull "$IMAGE_NAME" > /dev/null
LATEST_IMAGE_DIGEST=$(get_image_digest "$IMAGE_NAME")

# Get container id
CONTAINER_ID=$(get_container_id "$CONTAINER_NAME")
# If the container does not exist or if new image is available
# If the container does not exist
if [ -z "$CONTAINER_ID" ]; then
echo "Container $CONTAINER_NAME does not exist creating container... (searched for Container ID $CONTAINER_NAME)"
$RUN_COMMAND
else
echo "Container $CONTAINER_NAME exists : ID $CONTAINER_ID"

# Get container state
CONTAINER_STATE=$(get_container_state "$CONTAINER_NAME")
# If the container is stopped
if [ "$CONTAINER_STATE" == "false" ]; then
echo "Container $CONTAINER_NAME is stopped. Starting container..."
docker start "$CONTAINER_NAME"
fi

CONTAINER_IMAGE_DIGEST=$(get_container_image_digest "$CONTAINER_ID")

if [ "$CONTAINER_IMAGE_DIGEST" != "$LATEST_IMAGE_DIGEST" ]; then
echo "Container image is not up to date"
docker stop "$CONTAINER_NAME"
echo "Container $CONTAINER_NAME is stopped"
docker rm "$CONTAINER_NAME"
echo "Container $CONTAINER_NAME removed"
OLD_IMAGE_ID=$(get_image_id_from_digest "$CONTAINER_IMAGE_DIGEST")
docker rmi $OLD_IMAGE_ID
echo "Old image : $OLD_IMAGE_ID - removed"
$RUN_COMMAND
CONTAINER_ID=$(get_container_id "$CONTAINER_NAME")
echo "Container $CONTAINER_ID started with latest image $LATEST_IMAGE_DIGEST"
else
echo "Container $CONTAINER_ID is up and image is up to date, nothing to do"
fi
fi

Screenshot from the interface of a Synology NAS

5. Select settings in Task Scheduler and configure the Save output result to be saved in “docker/script-logs”.

Screenshot from the interface of a Synology NAS

Step 5: First-run and authentication

  1. Locate and run the task in the Task Scheduler.

  2. Confirm the Hivenet Docker container is active.

  3. For the first run, authenticate your node with your Hivenet account using one of two methods:

    • Via the Container Manager logs.

    • Or by checking the .hive/logs folder on your NAS.

Copy the URL you find in either and open it in a web browser. Follow the on-screen prompts to link your hive-node with your Hivenet account. You're all set once you see an “Agent started in…” line in the logs.

Screenshot from the interface of a Synology NAS

Hey, new Hiver!

Congratulations! You're now a proud part of the Hivenet community with your Synology NAS!

Did this answer your question?