Docker runs the Ethereum public chain

https://github.com/ethereum/go-ethereum/wiki/Running-in-Docker
Installation

If you rely on the core version support, you can download and install docker by executing the command directly.

yum install docker 

Execute the following command, if the specific version is displayed, the installation is successful.

docker version 

start up

service docker start

View mirror

Use the following command to view locally installed images.

docker images

The above briefly introduces the installation of docker. Different versions may encounter different problems. You can search and solve them by yourself. The following will mainly introduce the installation and use of ethereum under docker.

ethereum docker environment installation

First, the Ethereum client is recommended to use docker to start the service.

pull mirror

To install the Ethereum client image, just execute a simple command:

docker pull ethereum/client-go

After the installation is complete, execute the following command to verify whether the installation is successful. If you can see ethereum/client-Go in the list, the installation is successful:

docker images

start node

start a node

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

In this way, a node is successfully started. You may encounter a problem in this link. Docker is not responsible for managing the network firewall policy configuration. I have made specific firewall policy configuration so that it can be accessed from the external network.
The following is my configuration for docker in the firewall policy, for reference only. Different configuration items are added under the corresponding policy.

*nat

:PREROUTING ACCEPT [27:11935]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [598:57368]
:POSTROUTING ACCEPT [591:57092]
:DOCKER - [0:0]
-A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
-A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j DOCKER
-A POSTROUTING -s 192.168.0.0/16 ! -o docker0 -j MASQUERADE

COMMIT 
*filter
:INPUT ACCEPT [139291:461018923]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [127386:5251162]
:DOCKER - [0:0]
-A FORWARD -o docker0 -j DOCKER
-A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i docker0 ! -o docker0 -j ACCEPT
-A FORWARD -i docker0 -o docker0 -j ACCEPT
COMMIT 

A node has been started normally above, and this node is a full node connected to the real network. If you want to call the corresponding api through the rpc interface, you also need to add the corresponding configuration parameters to the startup parameters:

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

The "0.0.0.0" parameter will receive requests from all hosts on the 8545 interface. Use with caution on public networks!

If you want to interact with the JavaScript **console**, you can start the node with the following command:

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

Specify the blockchain data storage location

We all know that the blockchain data of Ethereum has reached dozens of G. If the disk is not enough for the disk space installed by docker, it will be troublesome. When I use it, I remount a disk to store block data exclusively. With the following command, you can specify the block data storage location at startup.

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

Among them, the -v parameter is used to specify the storage path. The basic function of this command is to mount /root/.ethereum to the local path /path/on/host. In this way, when the container starts, the actual storage of the file is in the /path/on/host directory.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325357063&siteId=291194637