Skip to content

Instantly share code, notes, and snippets.

@KEINOS
Last active October 27, 2022 01:21
Show Gist options
  • Select an option

  • Save KEINOS/df59f2683053bcb18c8bf053f278cca4 to your computer and use it in GitHub Desktop.

Select an option

Save KEINOS/df59f2683053bcb18c8bf053f278cca4 to your computer and use it in GitHub Desktop.
[IPFS] Example of Docker compose file for Kubo IPFS. Replace "</absolute/path/...>" to your local path.
version: "3.9"
services:
ipfs:
container_name: ipfs
image: ipfs/kubo:latest
volumes:
# Staging data
- </absolute/path/to/somewhere/>:/export
# IPFS data
- </absolute/path/to/somewhere_else/>:/data/ipfs
ports:
# P2P TCP/QUIC transports
- "4001:4001"
- "4001:4001/udp"
# Gateway
- "8080:8080"
# RPC API (Do not expose this port to public internet)
- "5001:5001"

Usage

For more details see: Run IPFS inside Docker @ docs.ipfs.tech

Note : Env info

  • Linux Ubuntu104 5.15.64-1-pve #1 SMP PVE 5.15.64-1 (Thu, 13 Oct 2022 10:30:34 +0200) x86_64 x86_64 x86_64 GNU/Linux
  • Docker version 20.10.21, build baeda1f

Start running container

# Run container on background
docker compose up -d

Stop running container

docker compose down

View log

docker compose logs ipfs

Connect to peers

docker compose exec ipfs ipfs swarm peers

Trouble shoot

[WebUI] Could not connect to the IPFS API

# Replace the IP address (192.168.***.***) to yours
docker compose exec ipfs ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://192.168.***.***:5001", "http://localhost:3000", "http://127.0.0.1:5001", "https://webui.ipfs.io"]'
docker compose exec ipfs ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST"]'
# Reboot container
docker compose restart ipfs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment