---
# System prepended metadata

title: 'Beginner''s Guide: Setting Up a Docker Container for Ethereum Node'

---

Beginner's Guide: Setting Up a Docker Container for Ethereum Node
=================================================================

Introduction
------------

Running an Ethereum node might sound complicated, but don't worry—this beginner-friendly guide will walk you through everything step by step. We'll set up a Docker container, install the necessary software, and configure both Geth (Ethereum client) and Lodestar (Ethereum consensus client). By the end, you'll have a fully functional Ethereum node running!

---

Step 1: Create a Docker Container
---------------------------------

### What is Docker?

Docker allows you to run applications in isolated environments called containers. Think of it as a mini virtual computer running inside your system.

### Creating the Container

Run the following command in your terminal to create a container based on Ubuntu Jammy:

```
docker run -dit --name eth_node --privileged --cgroupns=host --restart unless-stopped --network host ubuntu:jammy
```

Now, enter the container to start working inside it:

```
docker exec -it eth_node bash
```

---

Step 2: Update the System and Install Dependencies
--------------------------------------------------

### Why Update?

Updating ensures your system is using the latest security patches and software versions.

Run the following command to update your system:

```
apt-get update && apt-get upgrade -y
```

### Installing Essential Tools

Now, install the required software packages:

```
apt install -y \
  curl \
  wget \
  git \
  jq \
  nano \
  sudo \
  unzip \
  software-properties-common \
  ca-certificates \
  ufw \
  gnupg
```

Additional dependencies needed for development:

```
apt-get install -y curl git build-essential python3 python3-pip cmake libssl-dev pkg-config openssl
```

---

Step 3: Install Node.js
-----------------------

### What is Node.js?

Node.js is a JavaScript runtime that helps run Ethereum tools like Lodestar.

### Installing Node.js

We will use **NVM (Node Version Manager)** to install Node.js:

```
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
```

Now install and use Node.js version 20:

```
nvm install 20 && nvm use 20
```

Finally, install **Yarn**, a package manager:

```
npm install -g yarn
```

---

Step 4: Install Go (Required for Geth)
--------------------------------------

### What is Go?

Go (Golang) is a programming language required to build and run Geth.

### Installing Go

Download and install Go with these commands:

```
curl -LO https://go.dev/dl/go1.21.1.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.21.1.linux-amd64.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
source ~/.bashrc
```

---

Step 5: Create a JWT Secret
---------------------------

### What is a JWT Secret?

A JWT (JSON Web Token) secret is used to securely communicate between Ethereum clients.

### Creating the JWT File

```
mkdir -p /jwt
openssl rand -hex 32 > /jwt/jwt.hex  # Generates a 64-character hex secret
```

---

Step 6: Install Geth (Ethereum Execution Client)
------------------------------------------------

### What is Geth?

Geth is the Ethereum execution client that processes transactions and smart contracts.

### Installing Geth

Clone the Geth repository and build it:

```
git clone https://github.com/ethereum/go-ethereum.git
cd go-ethereum
make geth
cp build/bin/geth /usr/local/bin/
cd ..
```

#### Fixing Errors During Installation

If `make geth` fails, try reinstalling Go:

```
sudo apt remove golang-go  # Remove old Go installation
wget https://go.dev/dl/go1.22.4.linux-arm64.tar.gz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go1.22.4.linux-arm64.tar.gz
echo 'export PATH="$PATH:/usr/local/go/bin"' >> ~/.bashrc
source ~/.bashrc
make geth
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt update
sudo apt install -y ethereum
```

---

Step 7: Install and Build Lodestar (Ethereum Consensus Client)
--------------------------------------------------------------

### What is Lodestar?

Lodestar is the Ethereum consensus client that manages validators and ensures the blockchain remains secure.

### Installing Lodestar

```
git clone https://github.com/ChainSafe/lodestar.git
cd lodestar
yarn install --ignore-optional
yarn build
pip3 install setuptools --force-reinstall --user
npm rebuild
npm install --global yarn
yarn global add lerna
yarn global add typescript
rm -rf node_modules yarn.lock package-lock.json
yarn cache clean
yarn install
yarn workspace @lodestar/test-utils add datastore-level
yarn workspace @lodestar/spec-test-util add datastore-level
npm link
npm install -g @chainsafe/lodestar
cd ..
```

#### Fixing Errors

If the build fails, try these commands:

```
lerna run build
yarn workspace @lodestar/test-utils add datastore-level
yarn workspace @lodestar/spec-test-util add datastore-level
mkdir types
touch types/datastore-level.d.ts && echo "declare module 'datastore-level';" > types/datastore-level.d.ts
yarn install
lerna run build
```

---

Step 8: Create the Start Script
-------------------------------

### Why Create a Start Script?

Instead of typing multiple commands each time, a script will automate the process.

### Creating the Script

Create a file named `start.sh` and add the following:

```
#!/bin/bash

# Start Lodestar with JWT authentication
lodestar beacon \
  --network mainnet \
  --execution.urls http://localhost:8551 \
  --jwt-secret /jwt/jwt.hex &

# Start Geth with JWT authentication
geth \
  --http \
  --http.addr 0.0.0.0 \
  --http.api eth,net,web3,engine,admin \
  --authrpc.jwtsecret /jwt/jwt.hex \
  --authrpc.port 8551 \
  --authrpc.addr 0.0.0.0 &
```

Give it execution permission and run it:

```
chmod +x start.sh
./start.sh
```

---

Conclusion
----------

Congratulations! 🎉 You've successfully set up an Ethereum node using Docker. With Geth and Lodestar running, you are well on your way to learning about Ethereum Protocol!
