This is a creation in Article, where the information may have evolved or changed.
Recently, busy working, there was no time to publish a blog, but has not stopped the study of blockchain. Spend the weekend sharing one of the more recent big gains-using Docker to build and use Ethereum nodes. I have successfully built a development environment, test environment, full node environment. Follow-up will be a blog in the form of analysis, I hope that we pay more attention to discuss progress together.
Environment
The first attempt was installed on the cloud server CentOS 6.5. Since Docker requires more than 6 CentOS, the kernel version must be 2.6.32-431 or higher. Attempt to upgrade the CentOS kernel, but encountered some problems in the middle, did not solve the problem, simply upgrade the cloud server to the CentOS 7.2 version.
If you have a friend based on centos6.5 and temporarily cannot upgrade the system directly, refer to the following article for upgrade.
http://blog.csdn.net/taiyang1987912/article/details/42744019
Installing Docker
The following environment is based on centos7.2 other environments should not be a big difference, you can try it yourself.
Installation
If you rely on core version support, execute the command directly to download and install Docker.
install
Execute the following command, if the actual version is true, the installation succeeds.
version
Start
start
View image
Use the following command to view a locally installed image.
docker images
The above simple introduction of the installation of Docker, different versions may encounter different problems, we search to solve their own. The following will be the main introduction to the installation of Docker under Ethereum use.
Ethereum Docker Environment Installation
Preferred, the Ethereum client is recommended to use Docker to start the service.
Pull Mirror
To install an Ethereum client image, simply execute a simple command:
docker pull ethereum/client-go
After the installation is complete, execute the command to verify that the installation was successful, and if you see ethereum/client-go in the list, the installation is successful:
docker images
Start node
Start a node
-it-p30303:30303 ethereum/client-go
In this way, a node is successfully started. You may encounter a problem in this session. Docker is not responsible for the management of network firewall policy configuration, my side for the external network can access to the specific firewall policy configuration.
The following is my configuration for Docker in the firewall policy, for reference only. Different configuration items are added below the corresponding policy.
*nat :P rerouting Accept [27:11935] :input accept [0:0] :output ACCEPT [598:57368] :P ostrouting ACCEPT [591:57092] :D ocker-[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 masqueradecommit *filter:input Accept [139291:461018923]:forward accept [0:0] : OUTPUT ACCEPT [127386:5251162]:D ocker-[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 acceptcommit
The above has started a node normally, which is a full node connected to the real network. If you want to invoke the corresponding API through the RPC interface, you will also need to add the corresponding configuration parameters in the startup parameters:
-it-p8545:8545-p30303:30303 ethereum/client-go----"0.0.0.0"
The "0.0.0.0" parameter receives requests sent by all hosts on the 8545 interface, and the public network is used with caution!
If you want to interact with the JavaScript console, you can start the node with the following command:
-it-p30303:30303 ethereum/client-go console
Specify the blockchain data storage location
We all know that Ethereum blockchain data has reached dozens of G, if the disk is not enough Docker installed disk space is not enough, it is not troublesome. I used to re-mount a disk to specifically store chunk data. With the command, you can specify the chunk data storage location at startup.
-it-p30303:30303-v /path/on/host:/root/.ethereum ethereum/client-go
Where the-v parameter is used to specify the storage path. The basic function of this command is to mount the/root/.ethereum below the local path/path/on/host. This way, when the container starts, the file is actually stored in the/path/on/host directory.