Skip to content

Commit 415a4c5

Browse files
authored
Merge pull request #1969 from ipfs/docs/document-container-limits
docs: docker container limits
2 parents 022d971 + 8f42568 commit 415a4c5

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

.github/styles/pln-ignore.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ reproviding
195195
requesters
196196
retrievability
197197
roadmaps
198+
runtime
199+
runtime's
198200
rsa
199201
sandboxed
200202
satoshi
@@ -216,7 +218,7 @@ testground
216218
testnet
217219
toolkits
218220
trustlessly
219-
uncensorable
221+
uncensorable
220222
undialable
221223
uniswap
222224
unreachability

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

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Install IPFS Kubo inside Docker
33
description: You can run IPFS inside Docker to simplify your deployment processes, and horizontally scale your IPFS infrastructure.
4+
current-ipfs-version: v0.32.1
45
---
56

67
# Install IPFS Kubo inside Docker
@@ -20,7 +21,7 @@ You can run Kubo IPFS inside Docker to simplify your deployment processes, as we
2021
1. Start a container running ipfs and expose ports `4001` (P2P TCP/QUIC transports), `5001` (RPC API) and `8080` (Gateway):
2122

2223
```shell
23-
docker run -d --name ipfs_host -v $ipfs_staging:/export -v $ipfs_data:/data/ipfs -p 4001:4001 -p 4001:4001/udp -p 127.0.0.1:8080:8080 -p 127.0.0.1:5001:5001 ipfs/kubo:latest
24+
docker run -d --name ipfs_host -v $ipfs_staging:/export -v $ipfs_data:/data/ipfs -p 4001:4001 -p 4001:4001/udp -p 127.0.0.1:8080:8080 -p 127.0.0.1:5001:5001 ipfs/kubo:v0.32.1
2425
```
2526

2627
::: danger NEVER EXPOSE THE RPC API TO THE PUBLIC INTERNET
@@ -70,7 +71,7 @@ You can run Kubo IPFS inside Docker to simplify your deployment processes, as we
7071
When starting a container running ipfs for the first time with an empty data directory, it will call `ipfs init` to initialize configuration files and generate a new keypair. At this time, you can choose which profile to apply using the `IPFS_PROFILE` environment variable:
7172

7273
```shell
73-
docker run -d --name ipfs_host -e IPFS_PROFILE=server -v $ipfs_staging:/export -v $ipfs_data:/data/ipfs -p 4001:4001 -p 4001:4001/udp -p 127.0.0.1:8080:8080 -p 127.0.0.1:5001:5001 ipfs/kubo:latest
74+
docker run -d --name ipfs_host -e IPFS_PROFILE=server -v $ipfs_staging:/export -v $ipfs_data:/data/ipfs -p 4001:4001 -p 4001:4001/udp -p 127.0.0.1:8080:8080 -p 127.0.0.1:5001:5001 ipfs/kubo:v0.32.1
7475
```
7576

7677
## Customizing your node
@@ -105,19 +106,35 @@ docker run -d --name ipfs \
105106
See the `gateway` example on the [go-ipfs-docker-examples repository](https://github.com/ipfs-shipyard/go-ipfs-docker-examples)
106107
:::
107108
109+
## Configuring resource limits
110+
111+
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:
112+
113+
- `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`)
114+
- `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`)
115+
116+
Example:
117+
118+
```shell
119+
docker run # (....)
120+
--cpus="4.0" -e GOMAXPROCS=4 \
121+
--memory="8000m" -e GOMEMLIMIT=7500MiB \
122+
ipfs/kubo:v0.32.1
123+
```
124+
108125
## Private swarms inside Docker
109126

110127
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`.
111128

112129
```shell
113-
docker run -d --name ipfs_host -e IPFS_SWARM_KEY=<your swarm key> -v $ipfs_staging:/export -v $ipfs_data:/data/ipfs -p 4001:4001 -p 4001:4001/udp -p 127.0.0.1:8080:8080 -p 127.0.0.1:5001:5001 ipfs/kubo:latest
130+
docker run -d --name ipfs_host -e IPFS_SWARM_KEY=<your swarm key> -v $ipfs_staging:/export -v $ipfs_data:/data/ipfs -p 4001:4001 -p 4001:4001/udp -p 127.0.0.1:8080:8080 -p 127.0.0.1:5001:5001 ipfs/kubo:v0.32.1
114131
```
115132

116133
The swarm key initialization can also be done using docker secrets, and requires `docker swarm` or `docker-compose`:
117134

118135
```shell
119136
cat your_swarm.key | docker secret create swarm_key_secret -
120-
docker run -d --name ipfs_host --secret swarm_key_secret -e IPFS_SWARM_KEY_FILE=/run/secrets/swarm_key_secret -v $ipfs_staging:/export -v $ipfs_data:/data/ipfs -p 4001:4001 -p 4001:4001/udp -p 127.0.0.1:8080:8080 -p 127.0.0.1:5001:5001 ipfs/kubo:latest
137+
docker run -d --name ipfs_host --secret swarm_key_secret -e IPFS_SWARM_KEY_FILE=/run/secrets/swarm_key_secret -v $ipfs_staging:/export -v $ipfs_data:/data/ipfs -p 4001:4001 -p 4001:4001/udp -p 127.0.0.1:8080:8080 -p 127.0.0.1:5001:5001 ipfs/kubo:v0.32.1
121138
```
122139

123140
## Key rotation inside Docker
@@ -126,10 +143,10 @@ It is possible to do key rotation in an ephemeral container that is temporarily
126143

127144
```shell
128145
# given container named 'ipfs-test' that persists repo at /path/to/persisted/.ipfs
129-
docker run -d --name ipfs-test -v /path/to/persisted/.ipfs:/data/ipfs ipfs/kubo:latest
146+
docker run -d --name ipfs-test -v /path/to/persisted/.ipfs:/data/ipfs ipfs/kubo:v0.32.1
130147
docker stop ipfs-test
131148
132149
# key rotation works like this (old key saved under 'old-self')
133-
docker run --rm -it -v /path/to/persisted/.ipfs:/data/ipfs ipfs/kubo:latest key rotate -o old-self -t ed25519
150+
docker run --rm -it -v /path/to/persisted/.ipfs:/data/ipfs ipfs/kubo:v0.32.1 key rotate -o old-self -t ed25519
134151
docker start ipfs-test # will start with the new key
135152
```

0 commit comments

Comments
 (0)