Run IPFS in docker
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Andy c26113fe1f
always start on boot
6 years ago
data firt commit 6 years ago
.dockerignore firt commit 6 years ago
Dockerfile firt commit 6 years ago update readme 6 years ago
docker-compose.yml always start on boot 6 years ago
launch firt commit 6 years ago
sha512sum.txt firt commit 6 years ago

IPFS in Docker


Start the IPFS:

docker-compose up -d

This will initialize the node under data/.ipfs directory.

Then prepare the following functions and add them to your ~/.bash_aliases file:

function docker_helper_up() {
  command cd ~/git/$1
  docker-compose up -d "$1"
  command cd ~-

function docker_helper_exec_u() {
  command cd ~/git/$1
  docker-compose exec -w /home/user -u user "$1" "$@"
  command cd ~-

function ipfs-daemon() {
  docker_helper_up ipfs

function ipfs() {
  docker_helper_exec_u "$FUNCNAME" "$@"

Now you can use ipfs command as normal:

$ ipfs-daemon
$ ipfs config Addresses.Gateway /ip4/

$ ipfs id
$ ipfs swarm addrs --local
$ ipfs pin ls -q --type recursive
$ ipfs ls QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv
$ ipfs cat QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/quick-start

$ mkdir data/public
$ cp ~/Downloads/dog-on-moon.gif data/public
$ ipfs add -rw public

$ ipfs ls Qmdd7jNjEM4RXEnG8Y4ZikaqN6PUJkZ6bZuJZySEaFcuqY
QmagwXL3P4vPKiehXaPzYsHWc2F4hcPpnYEmm1AgQ4QLrU 2177241 dog-on-moon.gif

$ ipfs cat Qmdd7jNjEM4RXEnG8Y4ZikaqN6PUJkZ6bZuJZySEaFcuqY/dog-on-moon.gif | sha256sum
03f9ccb5d2a0e88acb60188e627042ef143c7fe5426c883863e78e66dab908d7  -
$ sha256sum ~/Downloads/dog-on-moon.gif
03f9ccb5d2a0e88acb60188e627042ef143c7fe5426c883863e78e66dab908d7  /home/arno/Downloads/dog-on-moon.gif

$ curl -s | sha256sum
03f9ccb5d2a0e88acb60188e627042ef143c7fe5426c883863e78e66dab908d7  -

Sharing stuff

To make sure your stuff gets shared across IPFS peers well, you need to make sure your ipfs-daemon listening on 4001/tcp port is accessible from the WAN.

Either configure your router to foward the traffic coming to 4001/tcp to your internal server/pc where your ipfs-daemon is running or just punch a port using the UPnP protocol like this:

$ sudo apt-get -y install miniupnpc
$ upnpc -r 4001 tcp

Your IGD (router/GW) must support UPnP for this to work.
You can delete the port published via UPnP by running upnpc -d 4001 tcp and list them upnpc -l.

After that you should see lots of traffic is coming to your port 4001/tcp:

sudo tcpdump -qenn -i eno1 src port 4001 and not src host 192.168

And ipfs reports lots of peers (>100 peers):

$ ipfs swarm peers
$ sudo nsenter -n -t $(pidof -s ipfs) netstat -tulpan | grep ESTABLISHED | wc -l

Then, when you've shared some stuff via the IPFS, you can try accessing it via any available public IPFS gateway (see link below).

It should return the content you've shared quickly.

You can also see how many IPFS servers shared your data by running:

ipfs dht findprovs QmW...

At the first you won't see more than one (your) IPFS server, but try to access it via some public IPFS GW and you will see more peers cached your file:

curl -sLI