Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit eadcde3

Browse files
docker readme
1 parent 387bbc1 commit eadcde3

1 file changed

Lines changed: 77 additions & 0 deletions

File tree

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,80 @@ There are two options when using the Avalanche-CLI:
9898

9999
1. Use an official Subnet-EVM release: https://docs.avax.network/subnets/build-first-subnet
100100
2. Build and deploy a locally built (and optionally modified) version of Subnet-EVM: https://docs.avax.network/subnets/create-custom-subnet
101+
102+
## Run in Docker
103+
104+
### Configuration
105+
106+
You can configure the `subnet-evm` Docker container using both environment variables and standard AvalancheGo config files.
107+
108+
- **Environment Variables**: Use uppercase variables prefixed with `AVAGO_`. For example, `AVAGO_NETWORK_ID` corresponds to the `--network-id` flag in AvalancheGo.
109+
- **Config Files**: Configure as you would with the regular AvalancheGo binary using config files. Ensure `HOME` is set to `/home/avalanche` and mount the config directory with `-v ~/.avalanchego:/home/avalanche/.avalanchego`.
110+
111+
### Data Persistence
112+
113+
To persist data across container restarts, you need to mount the `.avalanchego` directory.
114+
115+
- **Create Directory**: Run `mkdir -p ~/.avalanchego/staking` beforehand to create the necessary directories and avoid file system access issues.
116+
- **Set Permissions**: Run the container with `--user $(id -u):$(id -g)` to ensure proper access rights.
117+
- **Set Home and Mount**: Set `HOME` to `/home/avalanche` and mount the data directory with `-v ~/.avalanchego:/home/avalanche/.avalanchego`.
118+
119+
### Updating
120+
121+
Run `docker stop avago; docker rm avago;` then start a new container with the latest version tag in your `docker run` command.
122+
123+
### Networking
124+
125+
Using `--network host` is recommended to avoid any issues.
126+
127+
If you know what you are doing, you will need port `AVAGO_STAKING_PORT` (default `9651`) open for the validator to connect to the subnet. For the RPC server, open `AVAGO_HTTP_PORT` (default `9650`). Do not attempt to remap `AVAGO_STAKING_PORT` using the Docker `-p` flag (e.g., `-p 9651:1234`); it will not work. Instead, set `AVAGO_STAKING_PORT=1234` and then use `-p 1234:1234`.
128+
129+
### Example Configs
130+
131+
#### Fuji Subnet Validator
132+
133+
```bash
134+
mkdir -p ~/.avalanchego/staking; docker run -it -d \
135+
--name avago \
136+
--network host \
137+
-v ~/.avalanchego:/home/avalanche/.avalanchego \
138+
-e AVAGO_NETWORK_ID=fuji \
139+
-e AVAGO_PARTIAL_SYNC_PRIMARY_NETWORK=true \
140+
-e AVAGO_TRACK_SUBNETS=REPLACE_THIS_WITH_YOUR_SUBNET_ID \
141+
-e AVAGO_PUBLIC_IP_RESOLUTION_SERVICE=ifconfigme \
142+
-e AVAGO_PLUGIN_DIR=/avalanchego/build/plugins/ \
143+
-e HOME=/home/avalanche \
144+
--user $(id -u):$(id -g) \
145+
avaplatform/subnet-evm:v0.7.1
146+
```
147+
148+
- `AVAGO_PARTIAL_SYNC_PRIMARY_NETWORK`: Ensures you don't sync the X and C-Chains.
149+
- `AVAGO_PLUGIN_DIR`: Sets the directory for the `subnet-evm` plugin.
150+
- `AVAGO_TRACK_SUBNETS`: Sets the subnet ID to track. It will track all chains in the subnet.
151+
- `AVAGO_NETWORK_ID=fuji`: Sets the network ID to Fuji. Remove to sync Mainnet.
152+
- `AVAGO_PUBLIC_IP_RESOLUTION_SERVICE=ifconfigme`: Required for AWS EC2 instances to be accessed from outside AWS.
153+
154+
#### Fuji Subnet RPC
155+
156+
```bash
157+
const dockerCommand = (subnetID: string, chainID: string) => `mkdir -p ~/.avalanchego_rpc/staking; docker run -it -d \\
158+
--name rpc \\
159+
--network host \\
160+
-v ~/.avalanchego_rpc/:/home/avalanche/.avalanchego \\
161+
-e AVAGO_NETWORK_ID=fuji \\
162+
-e AVAGO_PARTIAL_SYNC_PRIMARY_NETWORK=true \\
163+
-e AVAGO_TRACK_SUBNETS=REPLACE_THIS_WITH_YOUR_SUBNET_ID \\
164+
-e AVAGO_HTTP_PORT=8080 \\
165+
-e AVAGO_STAKING_PORT=9653 \\
166+
-e AVAGO_HTTP_ALLOWED_HOSTS="*" \\
167+
-e AVAGO_HTTP_HOST=0.0.0.0 \\
168+
-e AVAGO_PUBLIC_IP_RESOLUTION_SERVICE=ifconfigme \\
169+
-e AVAGO_PLUGIN_DIR=/avalanchego/build/plugins/ \\
170+
-e HOME=/home/avalanche \\
171+
--user $(id -u):$(id -g) \\
172+
avaplatform/subnet-evm:v0.7.1`;
173+
```
174+
175+
- `AVAGO_STAKING_PORT` is set to `9653` in case you want to run this on the same machine as the validator.
176+
- `AVAGO_HTTP_PORT` is set to `8080` instead of `9650` to avoid conflicts with the validator.
177+
- `AVAGO_HTTP_ALLOWED_HOSTS` and `AVAGO_HTTP_HOST` are required to allow the RPC server to be accessed from outside. You'll need to secure it with HTTPS; Caddy is recommended.

0 commit comments

Comments
 (0)