-
-
Notifications
You must be signed in to change notification settings - Fork 353
Emulate private networking with Docker Compose
Sometime testing on mainnet or testnet is not suitable due to we can't control it. We can solve this problem by create a private network that we completely have control. With Docker Compose, we can easily achieve that.
- Docker
- Docker Compose
Create a new empty directory anywhere to store configurations that we are going to create. Then create docker-compose.yml
in that directory with the following content:
version: '3'
services:
zcoind-1:
container_name: zcoind-1
image: zcoinofficial/zcoind:latest
volumes:
- ./zcoind-1.conf:/home/zcoind/.zcoin/zcoin.conf
zcoind-2:
container_name: zcoind-2
image: zcoinofficial/zcoind:latest
volumes:
- ./zcoind-2.conf:/home/zcoind/.zcoin/zcoin.conf
zcoind-3:
container_name: zcoind-3
image: zcoinofficial/zcoind:latest
volumes:
- ./zcoind-3.conf:/home/zcoind/.zcoin/zcoin.conf
Create zcoind-1.conf
with the following content:
connect=zcoind-2
connect=zcoind-3
listen=1
Create zcoind-2.conf
with the following content:
connect=zcoind-1
connect=zcoind-3
listen=1
Create zcoind-3.conf
with the following content:
connect=zcoind-1
connect=zcoind-2
listen=1
If you need more nodes just add more configurations for it. You can put testnet=1
in a configuration to emulate testnet or regtest=1
to emulate in regression test mode.
Execute the following command in the directory that we created from previous instruction to start all nodes that we configured:
docker-compose up -d
If you does not have docker image specified in the configuration it will pulled automatically. -d
option mean we will start all nodes in a background. Verify if it already running:
docker ps
If you want to see the console output for node 1 use the following command:
docker logs zcoind-1
Verify connections on node 1:
docker exec zcoind-1 zcoin-cli getpeerinfo
You should see it is connected to all nodes that you specified with connect
option in the configuration file.
If you want to connect a node on your host machine to nodes in container just use the same connect
option. You can find IP address of each container with the following command:
docker inspect zcoind-1
To stop all nodes, execute the following command:
docker-compose down
- Home
- Information for exchanges
- Technical and Troubleshooting
- Deterministic Masternodes
- Exchanges and Partners
- Vulnerability bounty program