:toc:

= Substrate/Polkadot local chain

This gists contains a collection of docker-compose config for Polkadot and Substrate. You can find it https://gist.github.com/chevdor/be461d11c56baecb0e7bbcb920e964fb[here].

You may clone this gist with:

	git clone git@gist.github.com: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. You can create this alias with `alias dcp='docker-compose'`

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.

WARNING: It is likely that some of the docker-compose config no longer work for very old docker images.

== 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 "polkadot\|substrate\|tmp" | awk '{print $1}' | xargs docker network rm
	docker volume ls | grep "polkadot\|substrate\|tmp" | awk '{print $2}' | xargs docker volume rm

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

== 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/855b75b18a2e8f05b19633b2bbd8f00887aa9300/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/855b75b18a2e8f05b19633b2bbd8f00887aa9300/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/855b75b18a2e8f05b19633b2bbd8f00887aa9300/dcp-polkadot-5nodes-ui.yml -O /tmp/dcp-local.yml && docker-compose -f /tmp/dcp-local.yml up --force-recreate

== 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/f10ebbe5b51f54e75cc06e14cf3a2f521b231cd9/dcp-substrate-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-substrate-2nodes-ui.yml up --force-recreate

	wget https://gist.github.com/chevdor/be461d11c56baecb0e7bbcb920e964fb/raw/f10ebbe5b51f54e75cc06e14cf3a2f521b231cd9/dcp-substrate-2nodes-ui.yml -O /tmp/dcp-local.yml && docker-compose -f /tmp/dcp-local.yml up --force-recreate
