Setting Up Monero Node with Docker Compose

This guide will walk you through using Docker to run a Monero node with a simple docker-compose file. This method is compatible with Windows, macOS, and Linux, and it allows you to run a Monero node easily, making the setup process the same across different operating systems. This guide includes instructions for setting up Docker and running the node.


What This Will Do

The provided docker-compose.yml file sets up a Monero node using the havenodex/monerod Docker image. It will run the node and store the Monero blockchain data in a Docker volume, making it easy to start, stop, or restart without losing your data.


Prerequisites

  • Docker: A platform that lets you run applications in containers, making it easy to set up and run services like Monero nodes.
  • Docker Compose: A tool for defining and running multi-container Docker applications using a docker-compose.yml file.

Step-by-Step Guide

Step 1: Install Docker and Docker Compose

  1. Windows:

    • Download Docker Desktop from the official Docker website.
    • Run the installer and follow the prompts.
    • After installation, open Docker Desktop to start the Docker engine.
  2. macOS:

  3. Linux:

    • Open a terminal and run the following commands to install Docker:
      sudo apt update
      sudo apt install docker.io docker-compose -y
      
    • Start Docker:
      sudo systemctl start docker
      sudo systemctl enable docker
      
    • Verify the installation:
      docker --version
      docker-compose --version
      

Step 2: Create a Folder for Your Monero Node

  1. Choose a location on your computer where you want to keep the Docker configuration and blockchain data.

  2. Create a new folder named monero-node (or any name you prefer):

    mkdir monero-node
    cd monero-node
    
  3. Create the docker-compose.yml file:

    • In the monero-node folder, create a file named docker-compose.yml and add the following content:

      version: '3'
      
      services:
        monerod:
          image: havenodex/monerod:latest
          user: ${FIXUID:-1000}:${FIXGID:-1000}
          restart: unless-stopped
          volumes:
            - monero-mainnet-blockchain-data:/home/monero/.bitmonero
          ports:
            - 18080:18080
            - 18081:18081
            - 18089:18089
          command:
            - "--rpc-restricted-bind-ip=0.0.0.0"
            - "--rpc-restricted-bind-port=18089"
            - "--rpc-bind-port=18081"
            - "--no-igd"
            - "--enable-dns-blocklist"
            - "--prune-blockchain"
      
      volumes:
        monero-mainnet-blockchain-data:
      
    • This file defines a Monero node that runs inside a Docker container and maps the necessary ports.


Step 3: Start the Monero Node

  1. Open a terminal (or PowerShell on Windows) and navigate to the monero-node folder:

    cd /path/to/monero-node
    
  2. Start the Monero Node:

    • Run the following command to start the node:
      docker-compose up -d
      
    • The -d flag runs the container in the background, so your terminal stays free.
  3. Verify the Node is Running:

    • To check if the node is running, use:
      docker-compose ps
      
    • You should see the monerod service running.

Explanation of the docker-compose.yml File

  • version: '3': Specifies the version of Docker Compose syntax being used.
  • services: Defines the services (containers) that will run. Here, we have a single monerod service.
  • image: havenodex/monerod:latest: Uses the Monero daemon image from Docker Hub.
  • user: ${FIXUID:-1000}:${FIXGID:-1000}: Ensures that the container runs as a non-root user for better security. This user will have the same UID and GID as your current user.
  • volumes: Mounts a Docker volume to store Monero blockchain data persistently.
  • ports: Exposes the necessary ports to access the Monero node.
    • 18080: Public node port.
    • 18081: Local RPC port for faster access.
    • 18089: Restricted RPC port.
  • command: Custom command arguments for monerod to configure network settings and pruning.

Step 4: Accessing the Monero Node

  • Using a Monero Wallet: Connect your wallet to the node using http://<your-server-ip>:18081 for faster local access or http://<your-server-ip>:18089 if you want to use the restricted RPC interface.
  • Monitoring the Node: You can view logs to monitor the node’s activity:
    docker-compose logs -f monerod
    

Stopping and Updating the Node

  • Stop the Node:

    docker-compose down
    
    • This stops the node but keeps your data intact in the volume.
  • Update the Monero Image:

    • Pull the latest image:
      docker-compose pull
      
    • Restart with the new image:
      docker-compose up -d
      

Additional Tips

  • Running on a Server: For headless servers (no GUI), SSH into your server and follow the same steps. Ensure Docker is installed.
  • Disk Space: Running a full Monero node requires significant disk space. Make sure your monero-mainnet-blockchain-data volume has enough space for the blockchain. Aproximately 150GB is needed.
  • Security: Keep the monerod service updated to the latest version for security and performance improvements.
  • Public Nodes: You'll often find there are plenty of remote nodes you can use only which will save you some space, just be sure that you trust them or at least connect to them anonymously if you wont use one on your own machine.

Troubleshooting

  • Issue: Docker Compose command not found:

    • Make sure Docker Compose is properly installed and accessible in your PATH.
    • Restart your terminal or command prompt after installation.
  • Issue: Monero node isn’t accessible:

    • Verify that the firewall allows incoming traffic on ports 18080, 18081, and 18089.
    • Check that the Docker container is running using docker-compose ps.
  • Issue: Data not persisting between restarts:

    • Ensure that the volume monero-mainnet-blockchain-data is properly defined in docker-compose.yml.

What’s Next?

You now have a Monero node running on Docker, accessible from any machine in your network. This setup can be easily scaled or moved to another machine by copying the docker-compose.yml file and re-running docker-compose up. You cano now link your monero daemon up with your Haveno seednode or Haveno daemon.

Feel free to explore more advanced configurations or connect multiple Monero nodes for better redundancy. Happy exploring!