Run IPFS in docker
Go to file
2018-12-29 13:52:49 +01:00
data firt commit 2018-12-29 13:52:07 +01:00
.dockerignore firt commit 2018-12-29 13:52:07 +01:00
docker-compose.yml firt commit 2018-12-29 13:52:07 +01:00
Dockerfile firt commit 2018-12-29 13:52:07 +01:00
launch firt commit 2018-12-29 13:52:07 +01:00
README.md update readme 2018-12-29 13:52:49 +01:00
sha512sum.txt firt commit 2018-12-29 13:52:07 +01:00

IPFS in Docker

Usage

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 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 https://ipfs.io/ipfs/Qmdd7jNjEM4RXEnG8Y4ZikaqN6PUJkZ6bZuJZySEaFcuqY/dog-on-moon.gif | sha256sum
03f9ccb5d2a0e88acb60188e627042ef143c7fe5426c883863e78e66dab908d7  -