This is a creation in Article, where the information may have evolved or changed.
In the previous blog, we talked about how to build a Go-ethereum node based on Docker. As a developer, if you simply have a full node, you won't be able to meet the normal development. For example, to make a transfer transaction, you have to consider whether you have certain etc, can you withstand the high gas? Based on this, today's blog will show you how to build a private dev environment.
Method One: Leverage existing open source
First of all, introduce a ready-made ethereum/client-go:test tool image.
Download tool
Address: Https://github.com/pragmaticcoders/docker-geth-dev
Download the project through the ZIP package and unzip it into a directory where the Docker command will be executed. The structure of the directory is the same as the directory structure on GitHub, not shown here.
Build image
Execute the following command to build the image, which requires special attention during the execution of the command there is a "." In the end. , otherwise an error will occur:
-t ethereum/client-go.
Boot Mirror
Execute the following command to start mirroring:
---d-p8110:8110 ethereum/client-go:test
Be aware of the ports you are using here.
At this point a dev environment has been built, and three of these accounts have been initialized with a certain balance.
Configuration file Resolution
Genesis.json file:
{ "nonce":"0x00006d6f7264656e", "Difficulty":"0x20000", "Mixhash":"0x00000000000000000000000000000000000000647572616c65787365646c6578", "Coinbase":"0xde1e758511a7c67e7db93d1c23c1060a21db4615", "timestamp":"0x00", "Parenthash":"0x0000000000000000000000000000000000000000000000000000000000000000", "Extradata":"0x", "Gaslimit":"0x2fefd8", "Alloc":{"de1e758511a7c67e7db93d1c23c1060a21db4615": {"balance": " $"}, "
27dc8de9e9a1cb673543bd5fce89e83af09e228f":
{"balance": " 1100 " },"
d64a66c28 A6ae5150af5e7c34696502793b91ae7":
{"balance": " /"} }
}
This file is configured for the Genesis block file. Three accounts were initialized with 1000,1100 and 900, respectively. It is initialized to a 1000-li bonus account for miners, and as the mining will continue to increase, you may not be able to see the balance.
The following is a simple look at the contents of the Dockerfile file, in fact, is very simple, is to write the configuration file CP to the specified location of the Docker container. The special need to pay attention to is the port number, can be modified according to their own needs. For other content, please read the analysis yourself.
From Ethereum/client-go# Our own custom Bult geth that mines really fast# COPY Geth/usr/bin/geth# script that invokes with all those# command line OptionsCOPY Rungeth.docker/usr/bin/rungeth# These files and directory of Geth state belong together and must be# kept in sync if changes is ever made# Note We are taking advantage of Docker ' s copy-on-mount featureCOPY geth.password/root/geth.passwordcopy genesis.json/root/genesis.jsoncopy Ethereum/root/.ethereumentrypoint [] entrypoint ["/usr/bin/rungeth"]# RUN ["/usr/bin/rungeth"]# Use non-standard ports so don ' t accidently connect to real servers# XXX Docker inheritance doesn ' t override, it extends the port list ...EXPOSE8110EXPOSE30310EXPOSE6110
Method Two
This method is self-exploring, and can be used.
This method is very simple, just add the "–dev" parameter after executing the normal boot container command. However, this method does not create a batch of initial accounts as in the method above, but it is possible to mine, trade, and easily obtain accounts of different amounts.
Docker run-TD - M +M--Memory-swap -1 - P 8545:8545 - P 30303:30303 - v/mnt/docker/dev:/root/.Ethereum--Name Gethdev ethereum/client-go --Rpcapi"Db,eth,net,web3,personal,admin,miner" --Rpc--Rpcaddr"0.0.0.0" --Cache= + --Dev
The above is the start command when I start the adjustment.
Postscript
This blog is written here, if there are questions please message communication, I am also in the exploratory phase, inevitably there are omissions and shallow, but also hope that we discuss progress together. Focus on blogs and make progress together.