dockerコンテナethereumのインストール
17006 ワード
方法一:既存のオープンソースを利用する
既存のethereum/client-go:testツールミラーがあります.
1ダウンロードツール
アドレス:https://github.com/pragmaticcoders/docker-geth-dev プロジェクトをzipパッケージでダウンロードし、dockerコマンドを実行するディレクトリに解凍します.ディレクトリの構造はgithubの上のディレクトリ構造と同じです
2ミラーの構築
次のコマンドを実行して、ミラーを構築します.実行中にコマンドが最後に「.」であることに特に注意する必要があります.そうしないと、エラーが発生します.
3ミラーの起動
次のコマンドを実行してミラーを起動します.
ヒントgethという名前のミラーを作成したことがありますが、ethereum/client-go:testミラーをもう1つ作成するには名前を変更する必要があります.
私のすべてのdockerを見てください
ここでは、自分が使用しているポートに注意してください.これでdev環境の構築が完了し、そのうち3つのアカウントが一定の残高で初期化されました.
プロファイル、すなわち創始ブロックの情報を表示できます
このファイルは、創世ブロックを構成するファイルです.3つの口座を初期化した金額は、それぞれ10001100と900です.そのうち1000里に初期化された鉱夫奨励受入口座は、掘削が増加するにつれて、この残高ではない可能性があります.
Dockerfileファイルの内容を簡単に見てみましょう.実は簡単です.書いたプロファイルcpをdockerコンテナの指定された位置に移動します.特に注意が必要なのはポート番号で、自分の必要に応じて修正することができます.その他の内容は自分で分析を読んでください.
中に入る[root@i-nxhzfrjz docker-geth-dev-master]#vi rungeth.docker発見はgethインタラクティブプラットフォームへのコマンド
方法2
この方法は本人が自分で探求して得たもので、経験証は使用することができます.この方法は、通常の起動コンテナコマンドの実行後に「-dev」パラメータを追加するだけで簡単です.しかし、この方法では上記の方法のように初期化口座を作成することはありませんが、自分で鉱山を掘ったり、取引をしたりして、異なる金額の口座を簡単に得ることができます.
以上は本人起動時調整後の起動命令です.
既存のethereum/client-go:testツールミラーがあります.
1ダウンロードツール
アドレス:https://github.com/pragmaticcoders/docker-geth-dev プロジェクトをzipパッケージでダウンロードし、dockerコマンドを実行するディレクトリに解凍します.ディレクトリの構造はgithubの上のディレクトリ構造と同じです
2ミラーの構築
次のコマンドを実行して、ミラーを構築します.実行中にコマンドが最後に「.」であることに特に注意する必要があります.そうしないと、エラーが発生します.
[root@i-nxhzfrjz pgeth]# cd /root/pgeth/docker-geth-dev-master
[root@i-nxhzfrjz docker-geth-dev-master]# docker build -t ethereum/client-go:test .
Sending build context to Docker daemon 231.9 kB
Step 1 : FROM ethereum/client-go
---> 55b07edb552c
Step 2 : COPY rungeth.docker /usr/bin/rungeth
---> 3e485e2eff45
Removing intermediate container 510f2c24fde5
Step 3 : COPY geth.password /root/geth.password
---> 010367885703
Removing intermediate container e2b7fcd2cff8
Step 4 : COPY genesis.json /root/genesis.json
---> f6dac8264b7b
Removing intermediate container f0024ad206f2
Step 5 : COPY ethereum /root/.ethereum
---> b8caf6171332
Removing intermediate container 47970853367a
Step 6 : ENTRYPOINT /usr/bin/rungeth
---> Running in 978112e673ba
---> be7a5b4d2f48
Removing intermediate container 978112e673ba
Step 7 : EXPOSE 8110
---> Running in 3dcd44b81c24
---> 8af6494a1ada
Removing intermediate container 3dcd44b81c24
Step 8 : EXPOSE 30310
---> Running in 8cb2080288cb
---> 82ff692d638a
Removing intermediate container 8cb2080288cb
Step 9 : EXPOSE 6110
---> Running in 7fa0c0b4ef0d
---> 9f4c2abd84aa
Removing intermediate container 7fa0c0b4ef0d
Successfully built 9f4c2abd84aa
3ミラーの起動
次のコマンドを実行してミラーを起動します.
[root@i-nxhzfrjz docker-geth-dev-master]# docker run --name geth -d -p 8110:8110 ethereum/client-go:test
/usr/bin/docker-current: Error response from daemon: Conflict. The name "/geth" is already in use by container 92f3e8b2352998069662ee551f912b30c1ea69a96e645311b2ecd553288d3654. You have to remove (or rename) that container to be able to reuse that name..
ヒントgethという名前のミラーを作成したことがありますが、ethereum/client-go:testミラーをもう1つ作成するには名前を変更する必要があります.
私のすべてのdockerを見てください
[root@i-nxhzfrjz docker-geth-dev-master]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
92f3e8b23529 ethereum/client-go:test "/usr/bin/rungeth" 2 hours ago Created geth
7d3858a37e90 ethereum/client-go "geth console" 3 hours ago Exited (0) 3 hours ago compassionate_leavitt
f8c6a9193d8f ethereum/client-go "geth" 4 hours ago Exited (0) 3 hours ago naughty_bell
[root@i-nxhzfrjz docker-geth-dev-master]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ここでは、自分が使用しているポートに注意してください.これでdev環境の構築が完了し、そのうち3つのアカウントが一定の残高で初期化されました.
プロファイル、すなわち創始ブロックの情報を表示できます
[root@i-nxhzfrjz docker-geth-dev-master]# vi genesis.json
{
"nonce": "0x00006d6f7264656e",
"difficulty": "0x20000",
"mixhash": "0x00000000000000000000000000000000000000647572616c65787365646c6578",
"coinbase": "0xde1e758511a7c67e7db93d1c23c1060a21db4615",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x",
"gasLimit": "0x2FEFD8",
"alloc": {
"de1e758511a7c67e7db93d1c23c1060a21db4615": {
"balance": "1000"
},
"27dc8de9e9a1cb673543bd5fce89e83af09e228f": {
"balance": "1100"
},
"d64a66c28a6ae5150af5e7c34696502793b91ae7": {
"balance": "900"
}
}
}
このファイルは、創世ブロックを構成するファイルです.3つの口座を初期化した金額は、それぞれ10001100と900です.そのうち1000里に初期化された鉱夫奨励受入口座は、掘削が増加するにつれて、この残高ではない可能性があります.
Dockerfileファイルの内容を簡単に見てみましょう.実は簡単です.書いたプロファイルcpをdockerコンテナの指定された位置に移動します.特に注意が必要なのはポート番号で、自分の必要に応じて修正することができます.その他の内容は自分で分析を読んでください.
[root@i-nxhzfrjz docker-geth-dev-master]# vi Dockerfile
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 options
COPY rungeth.docker /usr/bin/rungeth
# these two files and directory of geth state belong together and must be
# kept in sync if changes are ever made
# Note we are taking advantage of Docker's copy-on-mount feature
COPY geth.password /root/geth.password
COPY genesis.json /root/genesis.json
COPY ethereum /root/.ethereum
ENTRYPOINT ["/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...
EXPOSE 8110
EXPOSE 30310
EXPOSE 6110
中に入る[root@i-nxhzfrjz docker-geth-dev-master]#vi rungeth.docker発見はgethインタラクティブプラットフォームへのコマンド
#!/bin/bash
if [ -f /usr/bin/geth ]; then
/usr/bin/geth --datadir /root/.ethereum --password /root/geth.password --unlock "0" --port 30310 --rpc --rpcaddr "0.0.0.0" -rpcapi "eth,web3" --rpcport 8110 --networkid 4567890 --dev --lightkdf --nodiscover --maxpeers 0 --verbosity 6 --pprof --pprofport 6110 --mine --minerthreads 1 $@ 2> /tmp/geth.log
else
./geth --datadir /root/.ethereum --password /root/geth.password --unlock "0" --port 30310 --rpc --rpcaddr "0.0.0.0" -rpcapi "eth,web3" --rpcport 8110 --networkid 4567890 --dev --lightkdf --nodiscover --maxpeers 0 --verbosity 6 --pprof --pprofport 6110 $@ 2> /tmp/geth.log
fi
方法2
この方法は本人が自分で探求して得たもので、経験証は使用することができます.この方法は、通常の起動コンテナコマンドの実行後に「-dev」パラメータを追加するだけで簡単です.しかし、この方法では上記の方法のように初期化口座を作成することはありませんが、自分で鉱山を掘ったり、取引をしたりして、異なる金額の口座を簡単に得ることができます.
docker run -td -m 512M --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=512 --dev
以上は本人起動時調整後の起動命令です.