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.

167 lines
4.3 KiB

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