go-ethereum/docs/_install-and-build/Running-in-Docker.md

3.1 KiB

title
Running in Docker

We keep a Docker image with recent snapshot builds from the develop branch on DockerHub. In addition to the container based on Ubuntu (158 MB), there is a smaller image using Alpine Linux (35 MB). To use the alpine tag, replace ethereum/client-go with ethereum/client-go:alpine in the examples below.

To pull the image, run this command:

docker pull ethereum/client-go

Start a node with:

docker run -it -p 30303:30303 ethereum/client-go

To start a node that runs the JSON-RPC interface on port 8545, run:

docker run -it -p 8545:8545 -p 30303:30303 ethereum/client-go --rpc --rpcaddr "0.0.0.0"

WARNING: This opens your container to external calls. "0.0.0.0" should not be used when exposed to public networks

To use the interactive JavaScript console, run:

docker run -it -p 30303:30303 ethereum/client-go console

Using Data Volumes

To persist downloaded blockchain data between container starts, use Docker data volumes. Replace /path/on/host with the location you want to store the data in.

docker run -it -p 30303:30303 -v /path/on/host:/root/.ethereum ethereum/client-go

We maintain four different docker images for running the latest stable or development versions of Geth.

  • ethereum/client-go:latest is the latest development version of Geth
  • ethereum/client-go:stable is the latest stable version of Geth
  • ethereum/client-go:{version} is the stable version of Geth at a specific version number
  • ethereum/client-go:release-{version} is the latest stable version of Geth at a specific version family

We also maintain four different docker images for running the latest stable or development versions of miscellaneous Ethereum tools.

  • ethereum/client-go:alltools-latest is the latest develop version of the Ethereum tools
  • ethereum/client-go:alltools-stable is the latest stable version of the Ethereum tools
  • ethereum/client-go:alltools-{version} is the stable version of the Ethereum tools at a specific version number
  • ethereum/client-go:alltools-release-{version} is the latest stable version of the Ethereum tools at a specific version family

The image has the following ports automatically exposed:

  • 8545 TCP, used by the HTTP based JSON RPC API
  • 8546 TCP, used by the WebSocket based JSON RPC API
  • 30303 TCP and UDP, used by the P2P protocol running the network
  • 30304 UDP, used by the P2P protocol's new peer discovery overlay

Note, if you are running an Ethereum client inside a docker container, you might want to mount in a data volume as the client's data directory (located at /root/.ethereum inside the container) to ensure that downloaded data is preserved between restarts and/or container life-cycles.