You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
4.3 KiB

  1. # Docker Compose
  2. With Docker Compose, you can spin up local testnets with a single command.
  3. ## Requirements
  4. 1. [Install tendermint](../introduction/install.md)
  5. 2. [Install docker](https://docs.docker.com/engine/installation/)
  6. 3. [Install docker-compose](https://docs.docker.com/compose/install/)
  7. ## Build
  8. Build the `tendermint` binary and, optionally, the `tendermint/localnode`
  9. docker image.
  10. Note the binary will be mounted into the container so it can be updated without
  11. rebuilding the image.
  12. ```
  13. cd $GOPATH/src/github.com/tendermint/tendermint
  14. # Build the linux binary in ./build
  15. make build-linux
  16. # (optionally) Build tendermint/localnode image
  17. make build-docker-localnode
  18. ```
  19. ## Run a testnet
  20. To start a 4 node testnet run:
  21. ```
  22. make localnet-start
  23. ```
  24. The nodes bind their RPC servers to ports 26657, 26660, 26662, and 26664 on the
  25. host.
  26. This file creates a 4-node network using the localnode image.
  27. The nodes of the network expose their P2P and RPC endpoints to the host machine
  28. on ports 26656-26657, 26659-26660, 26661-26662, and 26663-26664 respectively.
  29. To update the binary, just rebuild it and restart the nodes:
  30. ```
  31. make build-linux
  32. make localnet-stop
  33. make localnet-start
  34. ```
  35. ## Configuration
  36. The `make localnet-start` creates files for a 4-node testnet in `./build` by
  37. calling the `tendermint testnet` command.
  38. The `./build` directory is mounted to the `/tendermint` mount point to attach
  39. the binary and config files to the container.
  40. To change the number of validators / non-validators change the `localnet-start` Makefile target:
  41. ```
  42. localnet-start: localnet-stop
  43. @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
  44. docker-compose up
  45. ```
  46. The command now will generate config files for 5 validators and 3
  47. non-validators network.
  48. Before running it, don't forget to cleanup the old files:
  49. ```
  50. cd $GOPATH/src/github.com/tendermint/tendermint
  51. # Clear the build folder
  52. rm -rf ./build/node*
  53. ```
  54. ## Configuring abci containers
  55. To use your own abci applications with 4-node setup edit the [docker-compose.yaml](https://github.com/tendermint/tendermint/blob/master/docker-compose.yml) file and add image to your abci application.
  56. ```
  57. abci0:
  58. container_name: abci0
  59. image: "abci-image"
  60. build:
  61. context: .
  62. dockerfile: abci.Dockerfile
  63. command: <insert command to run your abci application>
  64. networks:
  65. localnet:
  66. ipv4_address: 192.167.10.6
  67. abci1:
  68. container_name: abci1
  69. image: "abci-image"
  70. build:
  71. context: .
  72. dockerfile: abci.Dockerfile
  73. command: <insert command to run your abci application>
  74. networks:
  75. localnet:
  76. ipv4_address: 192.167.10.7
  77. abci2:
  78. container_name: abci2
  79. image: "abci-image"
  80. build:
  81. context: .
  82. dockerfile: abci.Dockerfile
  83. command: <insert command to run your abci application>
  84. networks:
  85. localnet:
  86. ipv4_address: 192.167.10.8
  87. abci3:
  88. container_name: abci3
  89. image: "abci-image"
  90. build:
  91. context: .
  92. dockerfile: abci.Dockerfile
  93. command: <insert command to run your abci application>
  94. networks:
  95. localnet:
  96. ipv4_address: 192.167.10.9
  97. ```
  98. Override the [command](https://github.com/tendermint/tendermint/blob/master/networks/local/localnode/Dockerfile#L12) in each node to connect to it's abci.
  99. ```
  100. node0:
  101. container_name: node0
  102. image: "tendermint/localnode"
  103. ports:
  104. - "26656-26657:26656-26657"
  105. environment:
  106. - ID=0
  107. - LOG=$${LOG:-tendermint.log}
  108. volumes:
  109. - ./build:/tendermint:Z
  110. command: node --proxy_app=tcp://abci0:26658
  111. networks:
  112. localnet:
  113. ipv4_address: 192.167.10.2
  114. ```
  115. Similarly do for node1, node2 and node3 then [run testnet](https://github.com/tendermint/tendermint/blob/master/docs/networks/docker-compose.md#run-a-testnet)
  116. ## Logging
  117. Log is saved under the attached volume, in the `tendermint.log` file. If the
  118. `LOG` environment variable is set to `stdout` at start, the log is not saved,
  119. but printed on the screen.
  120. ## Special binaries
  121. If you have multiple binaries with different names, you can specify which one
  122. to run with the `BINARY` environment variable. The path of the binary is relative
  123. to the attached volume.