Subspace Node Setup Guide Using Docker

Table of Contents

Resources:

System Requirements:

  • Ubuntu 20.04 or higher

  • 2 dedicated CPU cores, 2GB RAM, 50GB disk space

Note: All commands should be entered into the console line by line.

Removing an Old Node (systemd)

If you have previously installed the node via systemd using my guide, remove it with the following commands:

sudo systemctl stop subspace-node subspace-farmer
sudo systemctl disable subspace-node subspace-farmer
sudo deluser subspace
sudo rm -rf /var/lib/subspace
sudo rm -rf /root/.local/share/subspace*
sudo rm /usr/local/bin/subspace*
sudo rm /etc/systemd/system/subspace*

Installation

Install Docker:

sudo -i
cd $HOME
# The following two commands may produce errors, which is normal
apt update && apt install curl -y && apt purge docker docker-engine docker.io containerd docker-compose -y
rm /usr/bin/docker-compose /usr/local/bin/docker-compose
curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
systemctl restart docker
curl -SL https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

Set environment variables for the node address and name. You can obtain an address here: Polkadot.js

# Replace with your reward address and desired node name
SUBSPACE_WALLET_ADDRESS="your_wallet_address"
SUBSPACE_NODE_NAME="your_node_name"
# Set the disk usage limit: G for gigabytes, T for terabytes
SUBSPACE_PLOT_SIZE="100G"

# Do not change anything here
echo 'export SUBSPACE_WALLET_ADDRESS='$SUBSPACE_WALLET_ADDRESS >> $HOME/.bash_profile
echo 'export SUBSPACE_NODE_NAME="'${SUBSPACE_NODE_NAME}'"' >> $HOME/.bash_profile
echo 'export SUBSPACE_PLOT_SIZE='$SUBSPACE_PLOT_SIZE >> $HOME/.bash_profile
source $HOME/.bash_profile

Create docker-compose.yml

mkdir $HOME/subspace
cd $HOME/subspace
tee $HOME/subspace/docker-compose.yml > /dev/null <<EOF
version: "3.7"
services:
  node:
    # For running on Aarch64 add '-aarch64' after 'DATE'
    image: ghcr.io/subspace/node:gemini-1b-2022-jun-18
    volumes:
      - node-data:/var/subspace:rw
    ports:
      - "0.0.0.0:30333:30333"
    restart: unless-stopped
    command: [
      "--chain", "gemini-1",
      "--base-path", "/var/subspace",
      "--execution", "wasm",
      "--pruning", "1024",
      "--keep-blocks", "1024",
      "--port", "30333",
      "--rpc-cors", "all",
      "--rpc-methods", "safe",
      "--unsafe-ws-external",
      "--validator",
      "--name", "$SUBSPACE_NODE_NAME"
    ]
    healthcheck:
      timeout: 5s
      interval: 30s
      retries: 5

  farmer:
    depends_on:
      node:
        condition: service_healthy
    image: ghcr.io/subspace/farmer:gemini-1b-2022-jun-18
    volumes:
      - farmer-data:/var/subspace:rw
    restart: unless-stopped
    command: [
      "--base-path", "/var/subspace",
      "farm",
      "--node-rpc-url", "ws://node:9944",
      "--ws-server-listen-addr", "0.0.0.0:9955",
      "--reward-address", "$SUBSPACE_WALLET_ADDRESS",
      "--plot-size", "$SUBSPACE_PLOT_SIZE"
    ]
volumes:
  node-data:
  farmer-data:
EOF

Start the Node:

docker-compose up -d

Viewing Logs

To view the logs, use:

docker-compose logs --tail=1000 -f

To display signed blocks:

docker-compose logs | grep "signed"

Note: Ensure you are in the same directory where the docker-compose.yml file is located when running these commands. If you log in again, navigate to the directory:

cd $HOME/subspace

You can find your node by name in telemetry: Subspace Telemetry

Test tokens earned from signing blocks will be credited to the specified address. Check your balance here: Polkadot.js

Upgrading to gemini-1b-2022-jun-18

This section is for those who have previously installed Subspace using this guide. If installed after June 21, 2022, skip these commands.

Navigate to the working directory:

sudo -i
cd $HOME/subspace

Update the release version:

sed -i.bak "s/:gemini-1b-2022.*/:gemini-1b-2022-jun-18/" docker-compose.yml

Restart the node and farmer:

docker-compose up -d

Removing the Node (docker)

cd $HOME/subspace
docker-compose down -v
cd $HOME && rm -rf $HOME/subspace/

String Theory socials:

Subscribe to String Theory
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.