基于 Docker 安装 IPFS

查看 IPFS 镜像

* 语法:docker search ipfs
* 示例: [root@izbp13xko46hud9vfr5s94z ~]# docker search ipfs NAME DESCRIPTION
STARS OFFICIAL AUTOMATED ipfs/go-ipfs Go implementationof IPFS, the
InterPlanetar…42 [OK] jbenet/go-ipfs 18 [OK] ipfs/ipfs-cluster Collective
pinningand composition for IPFS. 1 [OK] ipfs/ipfs-cluster-test Container used to
test ipfs-clusterwith kub… 1 [OK] maybebtc/go-ipfs 1 [OK]
mkg20001/ipfs-docker-webserver IPFS webserver poweredby apache2 as docker … 1
[OK] qnib/ipfs Docker imageto integrate ipfs into QNIBTerm… 1 [OK]
hanuprateek/zenko-ipfs-module0 victorbjelkholm/ipfsbin ipfsbin 0 [OK]
pataquets/beets-ipfs beets-ipfs0 [OK] nannal/ipfs 0 zenground0/ipfs-cluster 0
ipfs/js-ipfs IPFS implementationin JavaScript 0 [OK] brimstone/ipfs Inter
Planetary File System0 compulsivecoder/ubuntu-mono-ipfs A container for running
monoand ipfs on ubu… 0 [OK] blockchainlg/ipfs-service 0 guruvan/go-ipfs 0
controlplane/kubernetes-ipfs0 ademord/ipfs-peer 0
joshorig/ipfs-cluster-k8s-sidecar0 controlplane/ipfs-cluster-test 0 rtlong/ipfs
Tiny static buildsof the IPFS binary ~13MB 0 whyrusleeping/ipfs-blkchn 0
aragon/ipfs0 andrewdotnich/docker-ipfs Docker container to run an IPFS node.
http:/…0 [OK] [root@izbp13xko46hud9vfr5s94z ~]#
获取 IPFS镜像

从查询出来的镜像列表中选择一个即可,这里选择ipfs/go-ipfs。

* 语法:docker pull ipfs/go-ipfs
* 示例: [root@izbp13xko46hud9vfr5s94z ~]# docker pull ipfs/go-ipfs Using
default tag: latestlatest: Pulling from ipfs/go-ipfs 5497949500d2: Pull complete
9cfd2e6d2b64: Downloading [===================> ] 5.213MB/13.13MB 8167893b973a:
Download complete0f61f69d653d: Download complete 8a98c133507f: Download complete
9cfd2e6d2b64: Pull complete 8167893b973a: Pull complete 0f61f69d653d: Pull
complete8a98c133507f: Pull complete e9bc9df9b0ba: Pull complete b5b58acfc7ee:
Pull complete385a82e0ccbb: Pull complete Digest: sha256:31
cc5713ef3e3e81bf868cbb56c19de2d15d661743d8b6077804dee26e929ac5Status:
Downloaded newer image for ipfs/go-ipfs:latest [root@izbp13xko46hud9vfr5s94z ~]#
实例化一个IPFS容器实例

* 语法:docker run -d --name ipfs_host -v /develop/ipfs/export:/export -v
/develop/ipfs/data:/data/ipfs -p 4001:4001 -p 127.0.0.1:8181:8181 -p
127.0.0.1:5001:5001 ipfs/go-ipfs:latest
* 示例: [root@izbp13xko46hud9vfr5s94z ~]# docker run -d --name ipfs_host -v
/develop/ipfs/export:/export -v /develop/ipfs/data:/data/ipfs -p 4001:4001 -p
127.0.0.1:8181:8181 -p 127.0.0.1:5001:5001 ipfs/go-ipfs:latest 49
e2db3bd0fff0d2740b992ae049f9a8d5c62915af4111b9487d0c4b752ed7a3 [root
@izbp13xko46hud9vfr5s94z ~]#
查看IPFS日志

* 语法:docker logs -f ipfs_host
* 示例: [root@izbp13xko46hud9vfr5s94z ~]# docker logs -f ipfs_host Changing user
to ipfs ipfs version 0.4.15 Found IPFS fs-repo at /data/ipfs Initializing
daemon... Swarm listeningon /ip4/127.0.0.1/tcp/4001 Swarm listening on /ip4/
172.17.0.2/tcp/4001 Swarm listening on
/p2p-circuit/ipfs/Qmf8LCedmUMnhXJZA8FHdqkWqm1C4traJAVDEfjsmmBo5E Swarm
announcing /ip4/127.0.0.1/tcp/4001 Swarm announcing /ip4/172.17.0.2/tcp/4001
API server listeningon /ip4/0.0.0.0/tcp/5001 Gateway (readonly) server listening
on /ip4/0.0.0.0/tcp/8080 Daemon is ready
当看到以下内容的时,说明IPFS正在运行:
Gateway (readonly) server listening on /ip4/0.0.0.0/tcp/8080
运行IPFS命令

* 语法:docker exec ipfs_host ipfs <args...>
* 示例:
进入IPFS容器

* 语法:docker exec -it ipfs_host /bin/sh
* 示例: [root@izbp13xko46hud9vfr5s94z ~]# docker exec -it ipfs_host /bin/sh / #
在当前终端容器可输入IPFS命令,例如输入ipfs
[root@izbp13xko46hud9vfr5s94z ~]# docker exec -it ipfs_host /bin/sh / # ipfs
USAGE ipfs - Global p2p merkle-dag filesystem. ipfs [--config=<config> | -c]
[--debug=<debug> | -D] [--help=<help>] [-h=<h>] [--local=<local> | -L]
[--api=<api>] <command> ... SUBCOMMANDS BASIC COMMANDS init Initialize ipfs
local configuration add <path> Add a file to IPFS cat <ref> Show IPFS object
dataget <ref> Download IPFS objects ls <ref> List links from an object refs <ref
> List hashesof links from an object DATA STRUCTURE COMMANDS block Interact with
raw blocksin the datastore object Interact with raw dag nodes files Interact
with objects as if they were a unix filesystem dag Interact with IPLD documents
(experimental) ADVANCED COMMANDS daemon Start a long-running daemon process
mount Mount an IPFSread-only mountpoint resolve Resolve any type of name name
Publishand resolve IPNS names key Create and list IPNS name keypairs dns
Resolve DNS links pin Pin objectsto local storage repo Manipulate the IPFS
repository stats Various operational stats p2p Libp2p stream mounting filestore
Managethe filestore (experimental) NETWORK COMMANDS id Show info about IPFS
peers bootstrap Addor remove bootstrap peers swarm Manage connections to the
p2p network dht Querythe DHT for values or peers ping Measure the latency of a
connection diag Print diagnostics TOOL COMMANDS config Manage configuration
version Show ipfs version information update Download and apply go-ipfs updates
commands List all available commands Use 'ipfs <command>--help' to learn more
about each command. ipfs uses a repository in the local file system. By default,
the repo is located at ~/.ipfs. To change the repo location, set the $IPFS_PATH
environment variable: export IPFS_PATH=/path/to/ipfsrepo EXIT STATUS The CLI
willexit with one of the following values: 0 Successful execution. 1 Failed
executions. /#
参考链接:
https://github.com/ipfs/go-ipfs#docker-usage
<https://github.com/ipfs/go-ipfs#docker-usage>
https://my.oschina.net/u/2306127/blog/1613968
<https://my.oschina.net/u/2306127/blog/1613968>

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:[email protected]
QQ群:637538335
关注微信