Skip to content

0gfoundation/Docker-RPC

Repository files navigation

0G RPC Node - Docker Setup

A Docker-based setup for running a 0G Chain RPC node on Mainnet (Aristotle) or Testnet (Galileo).

Networks

Network Name Network ID Chain Spec
Mainnet Aristotle 16661 mainnet
Testnet Galileo 16602 testnet

Hardware Requirements

Component Mainnet Testnet
Memory 64 GB 64 GB
CPU 8 cores 8 cores
Disk 1 TB NVME SSD 4 TB NVME SSD
Bandwidth 100 MBps up/down 100 MBps up/down

Quick Start

Testnet (Galileo) - Default

# Build the Docker image
docker-compose build

# Start the node (set your external IP)
EXTERNAL_IP=<your-public-ip> docker-compose up -d

# View logs
docker-compose logs -f

Mainnet (Aristotle)

# Build the mainnet Docker image
DOCKERFILE=Dockerfile.mainnet NETWORK=aristotle docker-compose build

# Start the node (set your external IP)
DOCKERFILE=Dockerfile.mainnet NETWORK=aristotle EXTERNAL_IP=<your-public-ip> docker-compose up -d

# View logs
docker-compose logs -f

Configuration

Environment Variables

Variable Description Default
DOCKERFILE Dockerfile to use Dockerfile.testnet
NETWORK Network name (for container naming) galileo
MONIKER Node name my-0g-rpc-node
EXTERNAL_IP Your public IP for P2P (required) -
PERSISTENT_PEERS Comma-separated peer list -
SEEDS Comma-separated seed nodes -

Example with All Options

# Testnet with custom moniker and peers
EXTERNAL_IP=1.2.3.4 \
MONIKER=my-testnet-node \
PERSISTENT_PEERS=node_id@ip:port \
docker-compose up -d

# Mainnet with custom moniker
DOCKERFILE=Dockerfile.mainnet \
NETWORK=aristotle \
EXTERNAL_IP=1.2.3.4 \
MONIKER=my-mainnet-node \
docker-compose up -d

Check Node Status

# Check sync status
curl -s http://localhost:26657/status | jq '.result.sync_info'

# Check connected peers
curl -s http://localhost:26657/net_info | jq '.result.n_peers'

# Check latest block
curl -s http://localhost:26657/status | jq '.result.sync_info.latest_block_height'

# Test Geth JSON-RPC
curl -s -X POST -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
  http://localhost:8545

# Check supervisor process status
docker exec 0g-rpc-galileo supervisorctl status  # testnet
docker exec 0g-rpc-aristotle supervisorctl status  # mainnet

Exposed Ports

Port Service Description
8545 Geth HTTP JSON-RPC HTTP endpoint
8546 Geth WS JSON-RPC WebSocket endpoint
30303 Geth P2P Execution layer P2P
26656 0gchaind P2P Consensus layer P2P
26657 0gchaind RPC Tendermint RPC
1317 REST API Cosmos REST API
9090 gRPC gRPC endpoint
9091 gRPC Web gRPC Web endpoint

RPC Endpoints

Once synced, use these endpoints:

# Tendermint RPC
http://localhost:26657

# REST API
http://localhost:1317

# gRPC
localhost:9090

# Geth JSON-RPC
http://localhost:8545

# Geth WebSocket
ws://localhost:8546

Data Management

Backup

# Stop the node
docker-compose down

# Backup data volume
docker run --rm -v docker-rpc_0g-data:/data -v $(pwd)/backup:/backup \
  ubuntu tar cvf /backup/0g-backup.tar /data

Restore

# Restore from backup
docker run --rm -v docker-rpc_0g-data:/data -v $(pwd)/backup:/backup \
  ubuntu tar xvf /backup/0g-backup.tar -C /

Troubleshooting

View Logs

# All logs
docker-compose logs -f

# Geth logs only (testnet)
docker exec 0g-rpc-galileo cat /data/0g-home/log/geth.out.log

# 0gchaind logs only (testnet)
docker exec 0g-rpc-galileo cat /data/0g-home/log/0gchaind.out.log

# For mainnet, replace 'galileo' with 'aristotle'

Restart Services

# Restart entire container
docker-compose restart

# Restart just the node
docker-compose down && docker-compose up -d

Reset Data (Start Fresh)

# Stop and remove everything including data
docker-compose down -v

# Rebuild and start fresh
docker-compose up -d --build

Switching Networks

If switching from testnet to mainnet (or vice versa), you must remove the old data volume:

# Stop and remove container
docker-compose down

# Remove the data volume
docker volume rm docker-rpc_0g-data

# Build and start with new network
DOCKERFILE=Dockerfile.mainnet NETWORK=aristotle docker-compose build
DOCKERFILE=Dockerfile.mainnet NETWORK=aristotle EXTERNAL_IP=<ip> docker-compose up -d

File Structure

.
├── Dockerfile.testnet    # Testnet (Galileo) image
├── Dockerfile.mainnet    # Mainnet (Aristotle) image
├── docker-compose.yml    # Docker Compose configuration
├── entrypoint.sh         # Container entrypoint script
├── supervisord.conf      # Reference (generated at runtime)
└── README.md

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages