Forked from nhapentor/$Running a Private Ethereum Blockchain using Docker.markdown
Created
July 9, 2022 17:24
-
-
Save bennotti/2b289b5d57cd9bedfa0d9221e5e44d4a to your computer and use it in GitHub Desktop.
Setup and run a cluster of nodes to build a private Ethereum network in Docker environment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Running a Private Ethereum Blockchain using Docker | |
| -------------------- | |
| Put genesis.json, Dockerfile, docker-compose.yml and .env files together in the same folder. Then run the command. | |
| ``` | |
| docker-compose up | |
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # The ID of Ethereum Network | |
| NETWORK_ID=1212 | |
| # The password to create and access the primary account | |
| ACCOUNT_PASSWORD=5uper53cr3t |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: '3.7' | |
| services: | |
| geth-bootnode: | |
| hostname: geth-bootnode | |
| env_file: | |
| - .env | |
| image: geth-client | |
| build: | |
| context: . | |
| args: | |
| - ACCOUNT_PASSWORD=${ACCOUNT_PASSWORD} | |
| command: | |
| --nodekeyhex="b0ac22adcad37213c7c565810a50f1772291e7b0ce53fb73e7ec2a3c75bc13b5" | |
| --nodiscover | |
| --ipcdisable | |
| --networkid=${NETWORK_ID} | |
| --netrestrict="172.25.0.0/24" | |
| networks: | |
| chainnet: | |
| geth-rpc-endpoint: | |
| hostname: geth-rpc-endpoint | |
| env_file: | |
| - .env | |
| image: geth-client | |
| depends_on: | |
| - geth-bootnode | |
| command: | |
| --bootnodes="enode://af22c29c316ad069cf48a09a4ad5cf04a251b411e45098888d114c6dd7f489a13786620d5953738762afa13711d4ffb3b19aa5de772d8af72f851f7e9c5b164a@geth-bootnode:30303" | |
| --allow-insecure-unlock | |
| --http | |
| --http.addr="0.0.0.0" | |
| --http.api="eth,web3,net,admin,personal" | |
| --http.corsdomain="*" | |
| --networkid=${NETWORK_ID} | |
| --netrestrict="172.25.0.0/24" | |
| ports: | |
| - "8545:8545" | |
| networks: | |
| chainnet: | |
| geth-miner: | |
| hostname: geth-miner | |
| env_file: | |
| - .env | |
| image: geth-client | |
| depends_on: | |
| - geth-bootnode | |
| command: | |
| --bootnodes="enode://af22c29c316ad069cf48a09a4ad5cf04a251b411e45098888d114c6dd7f489a13786620d5953738762afa13711d4ffb3b19aa5de772d8af72f851f7e9c5b164a@geth-bootnode:30303" | |
| --mine | |
| --miner.threads=1 | |
| --networkid=${NETWORK_ID} | |
| --netrestrict="172.25.0.0/24" | |
| networks: | |
| chainnet: | |
| networks: | |
| chainnet: | |
| driver: bridge | |
| ipam: | |
| config: | |
| - subnet: 172.25.0.0/24 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM ethereum/client-go:v1.10.1 | |
| ARG ACCOUNT_PASSWORD | |
| COPY genesis.json /tmp | |
| RUN geth init /tmp/genesis.json \ | |
| && rm -f ~/.ethereum/geth/nodekey \ | |
| && echo ${ACCOUNT_PASSWORD} > /tmp/password \ | |
| && geth account new --password /tmp/password \ | |
| && rm -f /tmp/password | |
| ENTRYPOINT ["geth"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "config": { | |
| "chainId": 1212, | |
| "homesteadBlock": 0, | |
| "eip150Block": 0, | |
| "eip155Block": 0, | |
| "eip158Block": 0, | |
| "byzantiumBlock": 0, | |
| "constantinopleBlock": 0, | |
| "petersburgBlock": 0, | |
| "ethash": {} | |
| }, | |
| "difficulty": "1", | |
| "gasLimit": "8000000", | |
| "alloc": {} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment