Put genesis.json, Dockerfile, docker-compose.yml and .env files together in the same folder. Then run the command.
docker-compose up
| # The ID of Ethereum Network | |
| NETWORK_ID=1212 | |
| # The password to create and access the primary account | |
| ACCOUNT_PASSWORD=5uper53cr3t |
| 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 |
| 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"] |
| { | |
| "config": { | |
| "chainId": 1212, | |
| "homesteadBlock": 0, | |
| "eip150Block": 0, | |
| "eip155Block": 0, | |
| "eip158Block": 0, | |
| "byzantiumBlock": 0, | |
| "constantinopleBlock": 0, | |
| "petersburgBlock": 0, | |
| "ethash": {} | |
| }, | |
| "difficulty": "1", | |
| "gasLimit": "8000000", | |
| "alloc": {} | |
| } |