Skip to content

Instantly share code, notes, and snippets.

@chevdor
Last active March 1, 2022 07:06
Show Gist options
  • Save chevdor/be461d11c56baecb0e7bbcb920e964fb to your computer and use it in GitHub Desktop.
Save chevdor/be461d11c56baecb0e7bbcb920e964fb to your computer and use it in GitHub Desktop.
Docker compose for a polkadot local chain

Substrate/Polkadot local chain

This gists contains a collection of docker-compose config for Polkadot and Substrate.

You may clone this gist with:

git clone [email protected]:be461d11c56baecb0e7bbcb920e964fb.git

Then run each docker-compose config using:

docker-compose -f <file.yml> up --force-recreate
Note
Alternatively you can find below several one-liners that will download the config to your temp folder, pull and start containers, without the need to clone anything.
Note
I usually alias docker-compose as dcp and you will see dcp below.
Warning
If you get any message similar to ERROR: Pool overlaps with other one on this address space, please run the following commands:
docker network ls | grep tmp | awk '{print $1}' | xargs docker network rm
Note
By default, all commands will pull the latest tag for the polkadot/substrate images. This may not always be what you want. To get the tag 1.2.3 you can prepend TAG=1.2.3 to the command. For instance TAG=bbqb dcp -f dcp-substrate-2nodes-noui.yml up --force-recreate
Note
After starting the commands including a UI, you may reach the UI at http://localhost:80/. You need however to adjust the settings in the UI in order to switch from the Hosted node to your local node.

Docker environment cleanup

You can cleanup your docker ENV using the following:

docker ps -a | grep "polkadot\|substrate" | awk '{print $1}' | xargs docker stop | xargs docker rm
docker network ls | grep tmp | awk '{print $1}' | xargs docker network rm

This will NOT delete all your containers but only those related to polkadot or substrate.

Substrate

2 nodes

2 nodes no UI
dcp -f dcp-substrate-2nodes-noui.yml up --force-recreate
wget https://gist.github.com/chevdor/be461d11c56baecb0e7bbcb920e964fb/raw/b7391dadfd4901cb87d84d6785ea94b09d36de15/dcp-polkadot-5nodes-ui.yml -O /tmp/dcp-local.yml && docker-compose -f /tmp/dcp-local.yml up --force-recreate
2 nodes with UI
dcp -f dcp-substrate-2nodes-ui.yml up --force-recreate
wget https://gist.github.com/chevdor/be461d11c56baecb0e7bbcb920e964fb/raw/b7391dadfd4901cb87d84d6785ea94b09d36de15/dcp-substrate-2nodes-ui.yml -O /tmp/dcp-local.yml && docker-compose -f /tmp/dcp-local.yml up --force-recreate

Polkadot

2 nodes

2 nodes no UI
dcp -f dcp-polkadot-2nodes-noui.yml up --force-recreate
wget https://gist.github.com/chevdor/be461d11c56baecb0e7bbcb920e964fb/raw/b7391dadfd4901cb87d84d6785ea94b09d36de15/dcp-polkadot-2nodes-noui.yml -O /tmp/dcp-local.yml && docker-compose -f /tmp/dcp-local.yml up --force-recreate
2 nodes with UI
dcp -f dcp-polkadot-2nodes-ui.yml up --force-recreate
wget https://gist.github.com/chevdor/be461d11c56baecb0e7bbcb920e964fb/raw/b7391dadfd4901cb87d84d6785ea94b09d36de15/dcp-polkadot-2nodes-ui.yml -O /tmp/dcp-local.yml && docker-compose -f /tmp/dcp-local.yml up --force-recreate

5 nodes

5 nodes with UI
dcp -f dcp-polkadot-5nodes-ui.yml up --force-recreate
wget https://gist.github.com/chevdor/be461d11c56baecb0e7bbcb920e964fb/raw/b7391dadfd4901cb87d84d6785ea94b09d36de15/dcp-polkadot-5nodes-ui.yml -O /tmp/dcp-local.yml && docker-compose -f /tmp/dcp-local.yml up --force-recreate
version: '3'
services:
node_alice:
ports:
- "30333:30333"
- "9933:9933"
- "9944:9944"
image: chevdor/polkadot:${TAG:-latest}
volumes:
- "polkadot-data-alice:/data"
command: polkadot --chain=local --ws-external --validator --alice -d /data --node-key 0000000000000000000000000000000000000000000000000000000000000001
networks:
testing_net:
ipv4_address: 172.28.1.1
node_bob:
ports:
- "30344:30344"
- "9935:9935"
- "9945:9945"
image: chevdor/polkadot:${TAG:-latest}
volumes:
- "polkadot-data-bob:/data"
links:
- "node_alice:alice"
command: polkadot --chain=local --validator --bob -d /data --port 30344 --rpc-port 9935 --ws-port 9945 --bootnodes '/ip4/172.28.1.1/tcp/30333/p2p/QmQZ8TjTqeDj3ciwr93EJ95hxfDsb9pEYDizUAbWpigtQN'
networks:
testing_net:
ipv4_address: 172.28.1.2
ui:
image: chevdor/polkadot-ui
ports:
- "80:80"
volumes:
polkadot-data-alice:
polkadot-data-bob:
networks:
testing_net:
ipam:
driver: default
config:
- subnet: 172.28.0.0/16
version: '3'
services:
node_alice:
ports:
- "30333:30333"
- "9933:9933"
- "9944:9944"
image: chevdor/polkadot:${TAG:-latest}
volumes:
- "polkadot-data-alice:/data"
command: polkadot --chain=local --ws-external --validator --alice -d /data --node-key 0000000000000000000000000000000000000000000000000000000000000001
networks:
testing_net:
ipv4_address: 172.28.1.1
node_bob:
ports:
- "30344:30344"
- "9935:9935"
- "9945:9945"
image: chevdor/polkadot:${TAG:-latest}
volumes:
- "polkadot-data-bob:/data"
links:
- "node_alice:alice"
command: polkadot --chain=local --validator --bob -d /data --port 30344 --rpc-port 9935 --ws-port 9945 --bootnodes '/ip4/172.28.1.1/tcp/30333/p2p/QmQZ8TjTqeDj3ciwr93EJ95hxfDsb9pEYDizUAbWpigtQN'
networks:
testing_net:
ipv4_address: 172.28.1.2
ui:
image: chevdor/polkadot-ui
ports:
- "80:80"
volumes:
polkadot-data-alice:
polkadot-data-bob:
networks:
testing_net:
ipam:
driver: default
config:
- subnet: 172.28.0.0/16
version: '3'
services:
node_alice:
ports:
- "30333:30333"
- "9933:9933"
- "9944:9944"
image: chevdor/polkadot:${TAG:-latest}
volumes:
- "polkadot-data-alice:/data"
command: polkadot --chain=local --ws-external --validator --alice -d /data --node-key 0000000000000000000000000000000000000000000000000000000000000001
networks:
testing_net:
ipv4_address: 172.28.1.1
node_bob:
ports:
- "30344:30344"
- "9935:9935"
- "9945:9945"
image: chevdor/polkadot:${TAG:-latest}
volumes:
- "polkadot-data-bob:/data"
links:
- "node_alice:alice"
command: polkadot --chain=local --validator --bob -d /data --port 30344 --rpc-port 9935 --ws-port 9945 --bootnodes '/ip4/172.28.1.1/tcp/30333/p2p/QmQZ8TjTqeDj3ciwr93EJ95hxfDsb9pEYDizUAbWpigtQN'
networks:
testing_net:
ipv4_address: 172.28.1.2
node_charlie:
ports:
- "30335:30333"
image: chevdor/polkadot:${TAG:-latest}
volumes:
- "polkadot-data-charlie:/data"
links:
- "node_alice:alice"
command: polkadot --chain=local --validator --charlie -d /data --bootnodes '/ip4/172.28.1.1/tcp/30333/p2p/QmQZ8TjTqeDj3ciwr93EJ95hxfDsb9pEYDizUAbWpigtQN'
networks:
testing_net:
ipv4_address: 172.28.1.3
node_dave:
ports:
- "30336:30333"
image: chevdor/polkadot:${TAG:-latest}
volumes:
- "polkadot-data-dave:/data"
links:
- "node_alice:alice"
command: polkadot --chain=local --validator --dave -d /data --bootnodes '/ip4/172.28.1.1/tcp/30333/p2p/QmQZ8TjTqeDj3ciwr93EJ95hxfDsb9pEYDizUAbWpigtQN'
networks:
testing_net:
ipv4_address: 172.28.1.4
node_eve:
ports:
- "30337:30333"
image: chevdor/polkadot:${TAG:-latest}
volumes:
- "polkadot-data-eve:/data"
links:
- "node_alice:alice"
command: polkadot --chain=local --validator --eve -d /data --bootnodes '/ip4/172.28.1.1/tcp/30333/p2p/QmQZ8TjTqeDj3ciwr93EJ95hxfDsb9pEYDizUAbWpigtQN'
networks:
testing_net:
ipv4_address: 172.28.1.5
volumes:
polkadot-data-alice:
polkadot-data-bob:
polkadot-data-charlie:
polkadot-data-dave:
polkadot-data-eve:
networks:
testing_net:
ipam:
driver: default
config:
- subnet: 172.28.0.0/16
version: '3.1'
services:
node_alice:
ports:
- "30333:30333"
- "9933:9933"
- "9944:9944"
image: chevdor/substrate:${TAG:-latest}
volumes:
- "substrate-data-alice:/data"
command: substrate --chain=local purge-chain --ws-external --validator --alice -d /data --node-key 0000000000000000000000000000000000000000000000000000000000000001
networks:
testing_net:
ipv4_address: 172.28.1.1
node_bob:
ports:
- "30344:30344"
- "9935:9935"
- "9945:9945"
image: chevdor/substrate:${TAG:-latest}
volumes:
- "substrate-data-bob:/data"
links:
- "node_alice:alice"
command: substrate --chain=local --validator --bob -d /data --port 30344 --rpc-port 9935 --ws-port 9945 --bootnodes '/ip4/172.28.1.1/tcp/30333/p2p/QmQZ8TjTqeDj3ciwr93EJ95hxfDsb9pEYDizUAbWpigtQN'
networks:
testing_net:
ipv4_address: 172.28.1.2
volumes:
substrate-data-alice:
substrate-data-bob:
networks:
testing_net:
ipam:
driver: default
config:
- subnet: 172.28.0.0/16
version: '3'
services:
node_alice:
ports:
- "30333:30333"
- "9933:9933"
- "9944:9944"
image: chevdor/substrate:${TAG:-latest}
volumes:
- "substrate-data-alice:/data"
command: substrate --chain=local purge-chain --validator --alice -d /data --ws-external --node-key 0000000000000000000000000000000000000000000000000000000000000001
networks:
testing_net:
ipv4_address: 172.28.1.1
node_bob:
ports:
- "30344:30344"
- "9935:9935"
- "9945:9945"
image: chevdor/substrate:${TAG:-latest}
volumes:
- "substrate-data-bob:/data"
links:
- "node_alice:alice"
command: substrate --chain=local purge-chain --validator --bob -d /data --port 30344 --rpc-port 9935 --ws-port 9945 --bootnodes '/ip4/172.28.1.1/tcp/30333/p2p/QmQZ8TjTqeDj3ciwr93EJ95hxfDsb9pEYDizUAbWpigtQN'
networks:
testing_net:
ipv4_address: 172.28.1.2
ui:
image: chevdor/polkadot-ui
ports:
- "80:80"
volumes:
substrate-data-alice:
substrate-data-bob:
networks:
testing_net:
ipam:
driver: default
config:
- subnet: 172.28.0.0/16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment