Skip to content

Commit 4b9a800

Browse files
authored
docs: docker container limits
1 parent abb58b8 commit 4b9a800

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

docs/install/run-ipfs-inside-docker.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,22 @@ docker run -d --name ipfs \
105105
See the `gateway` example on the [go-ipfs-docker-examples repository](https://github.com/ipfs-shipyard/go-ipfs-docker-examples)
106106
:::
107107
108+
## Configuring resource limits
109+
110+
When deploying IPFS Kubo in containerized environments, it's crucial to align the Go runtime's resource awareness with the container's defined resource constraints via environment variables:
111+
112+
- `GOMAXPROCS`: Configures the maximum number of OS threads that can execute Go code concurrently (should not be bigger than the hard container limit set via `docker --cpus`)
113+
- `GOMEMLIMIT`: Sets the soft [memory allocation limit for the Go runtime](https://tip.golang.org/doc/gc-guide#Memory_limit) (should be slightly below the hard limit set for container via `docker --memory`)
114+
115+
Example:
116+
117+
```shell
118+
docker run --cpus="4.0" --memory="8000MiB" \
119+
--cpus="4.0" -e GOMAXPROCS=4 \
120+
--memory="8000m" -e GOMEMLIMIT=7500MiB \
121+
ipfs/kubo:latest
122+
```
123+
108124
## Private swarms inside Docker
109125

110126
It is possible to initialize the container with a swarm key file (`/data/ipfs/swarm.key`) using the variables `IPFS_SWARM_KEY` and `IPFS_SWARM_KEY_FILE`. The `IPFS_SWARM_KEY` creates `swarm.key` with the contents of the variable itself, while `IPFS_SWARM_KEY_FILE` copies the key from a path stored in the variable. The `IPFS_SWARM_KEY_FILE` **overwrites** the key generated by `IPFS_SWARM_KEY`.

0 commit comments

Comments
 (0)