Ethereum go-ethereum client docker installation (1)

Recently, I have been busy with work and have not had time to publish a blog, but I have not stopped researching the blockchain. Take time over the weekend to share one of the more significant recent gains - using docker to build and use Ethereum nodes. I have successfully built a development environment, a test environment, and a Full node environment. The follow-up will be analyzed one by one in the form of blogs. I hope everyone will pay more attention and discuss progress together.

environment

The first attempt was to install on centos 6.5 of the cloud server. Since docker requires centos to be above 6, and the kernel version must be 2.6.32-431 or higher. I tried to upgrade the centos kernel, but encountered some problems in the middle, which were not resolved smoothly, so I simply upgraded the cloud server to the centos 7.2 version.
If a friend is based on centos6.5 and cannot directly upgrade the system for the time being, you can refer to the following article to upgrade.
http://blog.csdn.net/taiyang1987912/article/details/42744019

install docker

The following environments are based on centos7.2. Other environments should not be too different. You can try it yourself.

Install

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

write picture description here

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 use the javascript console to interact interactively, 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=325356977&siteId=291194637