config-methods.md
1 --- 2 title: Node Configuration Methods 3 hide_table_of_contents: true 4 displayed_sidebar: runNode 5 --- 6 7 Waku nodes can be configured using a combination of the following methods: 8 9 1. Command line options and flags 10 2. Environment variables 11 3. TOML configuration files (currently the only supported format) 12 4. Default values 13 14 :::info 15 Take note of the precedence order: Each configuration method overrides the one below it (e.g., command line options override environment variables and configuration files). 16 ::: 17 18 ## Command line options 19 20 Node configuration is primarily done using command line options, which override other methods. Specify [configuration options](/run-node/config-options) by providing them in this format after the binary name: 21 22 ```shell 23 ./build/wakunode2 --tcp-port=65000 24 ``` 25 26 When running your node with Docker, provide the command line options after the image name in this format: 27 28 ```shell 29 docker run wakuorg/nwaku --tcp-port=65000 30 ``` 31 32 ## Environment variables 33 34 Nodes can be configured using environment variables by prefixing the variable name with `WAKUNODE2_` and using the configuration option in [SCREAMING_SNAKE_CASE](https://en.wiktionary.org/wiki/screaming_snake_case) format. 35 36 To set the `tcp-port` configuration, the `wakunode2` binary should be called in this format: 37 38 ```shell 39 WAKUNODE2_TCP_PORT=65000 ./build/wakunode2 40 ``` 41 42 When running your node with Docker, start the node using the `-e` command option: 43 44 ```shell 45 docker run -e "WAKUNODE2_TCP_PORT=65000" wakuorg/nwaku 46 ``` 47 48 :::info 49 This is the second configuration method in order of precedence. [Command Line Options](#command-line-options) override environment variables. 50 ::: 51 52 ## Configuration files 53 54 Nodes can be configured using a configuration file following the [TOML](https://toml.io/en/) format: 55 56 ```toml title="TOML Config File" showLineNumbers 57 log-level = "DEBUG" 58 tcp-port = 65000 59 topic = ["/waku/2/default-waku/proto"] 60 metrics-logging = false 61 ``` 62 63 The `config-file` [configuration option](/run-node/config-options) lets you specify the configuration file path: 64 65 ```shell 66 ./build/wakunode2 --config-file=[TOML CONFIGURATION FILE] 67 ``` 68 69 You can also specify the configuration file via environment variables: 70 71 ```shell 72 # Using environment variables 73 WAKUNODE2_CONFIG_FILE=[TOML CONFIGURATION FILE] ./build/wakunode2 74 75 # Using environment variables with Docker 76 docker run -e "WAKUNODE2_CONFIG_FILE=[TOML CONFIGURATION FILE]" wakuorg/nwaku 77 ``` 78 79 :::info 80 This is the third configuration method in order of precedence. [Command Line Options](#command-line-options) and [Environment Variables](#environment-variables) override configuration files. 81 ::: 82 83 ## Default configuration values 84 85 The default configuration is used when no other options are specified. By default, a `nwaku` node does the following: 86 87 - Generate a new `Node Key` and `PeerID`. 88 - Listen for incoming libp2p connections on the default TCP port (`60000`). 89 - Subscribe to the default Pub/Sub topic (`/waku/2/default-waku/proto`). 90 - Enable the `Relay` protocol for relaying messages. 91 - Enable the `Store` protocol as a client, allowing it to query peers for historical messages but not store any message itself. 92 93 To see the default values of all [configuration options](/run-node/config-options), run `wakunode2 --help`: 94 95 ```shell 96 ./build/wakunode2 --help 97 ``` 98 99 :::tip 100 To explore the available node configuration options, have a look at the [Node Configuration Options](/run-node/config-options) guide. 101 :::