github.com/number571/tendermint@v0.34.11-gost/docs/networks/docker-compose.md (about) 1 --- 2 order: 2 3 --- 4 5 # Docker Compose 6 7 With Docker Compose, you can spin up local testnets with a single command. 8 9 ## Requirements 10 11 1. [Install tendermint](../introduction/install.md) 12 2. [Install docker](https://docs.docker.com/engine/installation/) 13 3. [Install docker-compose](https://docs.docker.com/compose/install/) 14 15 ## Build 16 17 Build the `tendermint` binary and, optionally, the `tendermint/localnode` 18 docker image. 19 20 Note the binary will be mounted into the container so it can be updated without 21 rebuilding the image. 22 23 ```sh 24 # Build the linux binary in ./build 25 make build-linux 26 27 # (optionally) Build tendermint/localnode image 28 make build-docker-localnode 29 ``` 30 31 ## Run a testnet 32 33 To start a 4 node testnet run: 34 35 ```sh 36 make localnet-start 37 ``` 38 39 The nodes bind their RPC servers to ports 26657, 26660, 26662, and 26664 on the 40 host. 41 42 This file creates a 4-node network using the localnode image. 43 44 The nodes of the network expose their P2P and RPC endpoints to the host machine 45 on ports 26656-26657, 26659-26660, 26661-26662, and 26663-26664 respectively. 46 47 The first node (`node0`) exposes two additional ports: 6060 for profiling using 48 [`pprof`](https://golang.org/pkg/net/http/pprof), and `9090` - for Prometheus 49 server (if you don't know how to start one check out ["First steps | 50 Prometheus"](https://prometheus.io/docs/introduction/first_steps/)). 51 52 To update the binary, just rebuild it and restart the nodes: 53 54 ```sh 55 make build-linux 56 make localnet-start 57 ``` 58 59 ## Configuration 60 61 The `make localnet-start` creates files for a 4-node testnet in `./build` by 62 calling the `tendermint testnet` command. 63 64 The `./build` directory is mounted to the `/tendermint` mount point to attach 65 the binary and config files to the container. 66 67 To change the number of validators / non-validators change the `localnet-start` Makefile target [here](../../Makefile): 68 69 ```makefile 70 localnet-start: localnet-stop 71 @if ! [ -f build/node0/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/tendermint:Z tendermint/localnode testnet --v 5 --n 3 --o . --populate-persistent-peers --starting-ip-address 192.167.10.2 ; fi 72 docker-compose up 73 ``` 74 75 The command now will generate config files for 5 validators and 3 76 non-validators. Along with generating new config files the docker-compose file needs to be edited. 77 Adding 4 more nodes is required in order to fully utilize the config files that were generated. 78 79 ```yml 80 node3: # bump by 1 for every node 81 container_name: node3 # bump by 1 for every node 82 image: "tendermint/localnode" 83 environment: 84 - ID=3 85 - LOG=${LOG:-tendermint.log} 86 ports: 87 - "26663-26664:26656-26657" # Bump 26663-26664 by one for every node 88 volumes: 89 - ./build:/tendermint:Z 90 networks: 91 localnet: 92 ipv4_address: 192.167.10.5 # bump the final digit by 1 for every node 93 ``` 94 95 Before running it, don't forget to cleanup the old files: 96 97 ```sh 98 # Clear the build folder 99 rm -rf ./build/node* 100 ``` 101 102 ## Configuring ABCI containers 103 104 To use your own ABCI applications with 4-node setup edit the [docker-compose.yaml](https://github.com/number571/tendermint/blob/master/docker-compose.yml) file and add image to your ABCI application. 105 106 ```yml 107 abci0: 108 container_name: abci0 109 image: "abci-image" 110 build: 111 context: . 112 dockerfile: abci.Dockerfile 113 command: <insert command to run your abci application> 114 networks: 115 localnet: 116 ipv4_address: 192.167.10.6 117 118 abci1: 119 container_name: abci1 120 image: "abci-image" 121 build: 122 context: . 123 dockerfile: abci.Dockerfile 124 command: <insert command to run your abci application> 125 networks: 126 localnet: 127 ipv4_address: 192.167.10.7 128 129 abci2: 130 container_name: abci2 131 image: "abci-image" 132 build: 133 context: . 134 dockerfile: abci.Dockerfile 135 command: <insert command to run your abci application> 136 networks: 137 localnet: 138 ipv4_address: 192.167.10.8 139 140 abci3: 141 container_name: abci3 142 image: "abci-image" 143 build: 144 context: . 145 dockerfile: abci.Dockerfile 146 command: <insert command to run your abci application> 147 networks: 148 localnet: 149 ipv4_address: 192.167.10.9 150 151 ``` 152 153 Override the [command](https://github.com/number571/tendermint/blob/master/networks/local/localnode/Dockerfile#L12) in each node to connect to it's ABCI. 154 155 ```yml 156 node0: 157 container_name: node0 158 image: "tendermint/localnode" 159 ports: 160 - "26656-26657:26656-26657" 161 environment: 162 - ID=0 163 - LOG=$${LOG:-tendermint.log} 164 volumes: 165 - ./build:/tendermint:Z 166 command: node --proxy-app=tcp://abci0:26658 167 networks: 168 localnet: 169 ipv4_address: 192.167.10.2 170 ``` 171 172 Similarly do for node1, node2 and node3 then [run testnet](https://github.com/number571/tendermint/blob/master/docs/networks/docker-compose.md#run-a-testnet) 173 174 ## Logging 175 176 Log is saved under the attached volume, in the `tendermint.log` file. If the 177 `LOG` environment variable is set to `stdout` at start, the log is not saved, 178 but printed on the screen. 179 180 ## Special binaries 181 182 If you have multiple binaries with different names, you can specify which one 183 to run with the `BINARY` environment variable. The path of the binary is relative 184 to the attached volume.