
Run an Ethereum Node with Docker and Geth — Complete Setup Guide
Step-by-step guide to setting up a Docker container that runs an Ethereum node using Geth (Go Ethereum client) and enables you to interact with the blockchain.
Overview
Step-by-step guide to setting up a Docker container that runs an Ethereum node using Geth, the Go Ethereum client.
1. Install Docker
docker --version
2. Pull the Official Ethereum Client Image
docker pull ethereum/client-go
3. Running the Ethereum Node in a Container
docker run -d \
--name geth_node \
-v $(pwd)/ethereum_data:/root/.ethereum \
-p 30303:30303 \
-p 8545:8545 \
ethereum/client-go \
--syncmode "fast" \
--rpc \
--rpcaddr "0.0.0.0" \
--rpcport "8545" \
--rpcapi "eth,net,web3,personal"
Key flags:
-v $(pwd)/ethereum_data:/root/.ethereum— persists blockchain data-p 30303:30303— P2P networking port-p 8545:8545— JSON-RPC API port--syncmode "fast"— speeds up the sync process
4. Using Docker Compose
version: '3'
services:
geth:
image: ethereum/client-go
container_name: gethnode
volumes:
- ./ethereum_data:/root/.ethereum
ports:
- "30303:30303"
- "8545:8545"
command:
- --syncmode
- fast
- --rpc
- --rpcaddr
- 0.0.0.0
- --rpcport
- "8545"
- --rpcapi
- personal,db,eth,net,web3
docker-compose up -d
5. Interacting with the Node
const Web3 = require('web3');
const web3 = new Web3('http://localhost:8545');
web3.eth.getBlockNumber().then(console.log);
6. Making the Node Reachable: Static IP or a Cloudflare Tunnel
Everything above runs on localhost, but a real node needs a stable address the outside world can reach:
- Static IP — home ISPs rotate your public IP every few days; ask your ISP for a static IP (usually a small monthly fee) so port forwards and peer addresses keep working
- Dynamic DNS (DDNS) — the free alternative: DuckDNS or No-IP gives you a hostname (yourname.duckdns.org) that always tracks your current IP, updated by a small client on the node
- DHCP reservation — pin the node machine's internal IP in your router so its forwards never break
- Cloudflare Tunnel — the no-open-ports option for RPC: install
cloudflared, create a tunnel, and route a hostname tohttp://localhost:8545so remote apps reach your RPC over HTTPS with your home IP hidden
cloudflared tunnel login
cloudflared tunnel create geth-node
cloudflared tunnel route dns geth-node geth.yourdomain.com
# ~/.cloudflared/config.yml
tunnel: geth-node
credentials-file: /home/you/.cloudflared/<tunnel-id>.json
ingress:
- hostname: geth.yourdomain.com
service: http://localhost:8545
- service: http_status:404
cloudflared tunnel run geth-node
Note: raw P2P traffic (port 30303) still wants a real port forward — arbitrary TCP through a tunnel needs a cloudflared access helper on the client side, while HTTP-style traffic like RPC works transparently.
7. Additional Considerations
- Data Persistence — Back up the ./ethereum_data folder
- Network Modes — Add --testnet flag for testnets
- Security — Use a firewall or NGINX reverse proxy before exposing the RPC endpoint publicly
- Resource Usage — A fully synced node is resource-intensive; set Docker memory and CPU limits as needed
Also featured on TechDerks Insights
I write more takes like this one on my second blog — blockchain deep dives, security breakdowns, and builder tools.
Read more on TechDerks InsightsDerrk Samuel
Web3, crypto, and Linux PC insights — practical guides, security tips, mining setups, blockchain tools, and decentralized tech strategies for techs.
Related Articles
Discussion
Leave a comment
No comments yet. Be the first to start the discussion!

