当前位置: 首页 > 软件库 > 云计算 > >

ipdr

🐋 IPFS-backed Docker Registry
授权协议 MIT License
开发语言 Google Go
所属分类 云计算
软件类型 开源软件
地区 不详
投 递 者 姚鹤龄
操作系统 跨平台
开源组织
适用人群 未知
 软件概览


logo


IPDR: InterPlanetary Docker Registry

IPFS-backed Docker Registry

IPDR is a Docker Registry tool that proxies Docker registry requests to IPFS for pushing and pulling images. IPDR allows you to store Docker images on IPFS instead of a central registry like Docker Hub or Google Container Registry. Docker images are referenced by their IPFS hash instead of the repo tag names.

IPDR is compatabile with the Docker Registry HTTP API V2 Spec for pulling images*

*not fully 1:1 implemented yet

High-level overview:

logo

Contents

Install

  • Install with Go:

    go get -u github.com/ipdr/ipdr/cmd/ipdr
  • Install from release binaries:

    # replace x.x.x with the latest version
    wget https://github.com/ipdr/ipdr/releases/download/x.x.x/ipdr_x.x.x_linux_amd64.tar.gz
    tar -xvzf ipdr_x.x.x_linux_amd64.tar.gz ipdr
    ./ipdr --help
    
    # move to bin path
    sudo mv ipdr /usr/local/bin/ipdr

Getting started

Prerequisites

  • Start IPFS daemon (Install instructions):

    $ ipfs daemon
    Initializing daemon...
    Swarm listening on /ip4/127.0.0.1/tcp/4001
    Swarm listening on /ip4/192.168.86.90/tcp/4001
    Swarm listening on /ip6/::1/tcp/4001
    Swarm listening on /p2p-circuit/ipfs/QmR29wrbNv3WrMuodwuLiDwvskuZKKeTtcYDw7SwNffzCH
    Swarm announcing /ip4/127.0.0.1/tcp/4001
    Swarm announcing /ip4/192.168.0.21/tcp/43042
    Swarm announcing /ip4/192.168.86.90/tcp/4001
    Swarm announcing /ip6/::1/tcp/4001
    API server listening on /ip4/0.0.0.0/tcp/5001
    Gateway (readonly) server listening on /ip4/0.0.0.0/tcp/8080
    Daemon is ready
  • Add docker.local to /etc/hosts:

    echo '127.0.0.1 docker.local' | sudo tee -a /etc/hosts
    echo '::1       docker.local' | sudo tee -a /etc/hosts
    
    • Flush local DNS cache:

      • on macOS:

        dscacheutil -flushcache; sudo killall -HUP mDNSResponder
      • on Ubuntu 18+:

        sudo systemd-resolve --flush-caches

Example flow

  • Create Dockerfile:

    FROM busybox:latest
    
    CMD echo 'hello world'
  • Build Docker image:

    docker build -t example/helloworld .

    Test run:

    $ docker run example/helloworld:latest
    hello world
  • Use IPDR CLI to push to IPFS:

    $ ipdr push example/helloworld
    
    INFO[0000] [registry] temp: /var/folders/k1/m2rmftgd48q97pj0xf9csdb00000gn/T/205139235
    INFO[0000] [registry] preparing image in: /var/folders/k1/m2rmftgd48q97pj0xf9csdb00000gn/T/657143846
    INFO[0000]
    [registry] dist: /var/folders/k1/m2rmftgd48q97pj0xf9csdb00000gn/T/657143846/default/blobs/sha256:305510b2c684403553fd8f383e8d109b147df2cfde60e40a85564532c383c8b8
    INFO[0000] [registry] compressing layer: /var/folders/k1/m2rmftgd48q97pj0xf9csdb00000gn/T/205139235/886f4bdfa483cc176e947c63d069579785c051793a9634f571fded7b9026cd3c/layer.tar
    INFO[0000] [registry] root dir: /var/folders/k1/m2rmftgd48q97pj0xf9csdb00000gn/T/657143846
    INFO[0000] [registry] upload hash QmRxZ5Wffj6b1j8ckJLcr7yFrbHUhBYXsAMbj7Krwu1pp8
    INFO[0000]
    [registry] uploaded to /ipfs/Qmc2ot2NQadXmbvPbsidyjYDvPfPwKZmovzNpfRPKxXUrL
    INFO[0000] [registry] docker image ciqmw4mig2uwaygddjlutoywq43udutvdmuxkcxvetsjp2mjdde27wi
    
    Successfully pushed Docker image to IPFS:
    /ipfs/Qmc2ot2NQadXmbvPbsidyjYDvPfPwKZmovzNpfRPKxXUrL
  • Use IPDR CLI to pull from IPFS:

    $ ipdr pull /ipfs/QmagW4H1uE5rkm8A6iVS8WuiyjcWQzqXRHbM3KuUfzrCup
    
    INFO[0000] [registry/server] port 5000
    INFO[0000] [registry] attempting to pull docker.local:5000/ciqmw4mig2uwaygddjlutoywq43udutvdmuxkcxvetsjp2mjdde27wi
    INFO[0000] [registry/server] /v2/
    INFO[0000] [registry/server] /v2/ciqmw4mig2uwaygddjlutoywq43udutvdmuxkcxvetsjp2mjdde27wi/manifests/latest
    INFO[0000] [registry/server] location http://127.0.0.1:8080/ipfs/Qmc2ot2NQadXmbvPbsidyjYDvPfPwKZmovzNpfRPKxXUrL/manifests/latest-v2
    {"status":"Pulling from ciqmw4mig2uwaygddjlutoywq43udutvdmuxkcxvetsjp2mjdde27wi","id":"latest"}
    {"status":"Digest: sha256:1fb36e4704d6ebad5becdcfe996807de5f8db687da396330f112157c888c165b"}
    {"status":"Status: Downloaded newer image for docker.local:5000/ciqmw4mig2uwaygddjlutoywq43udutvdmuxkcxvetsjp2mjdde27wi:latest"}
    
    Successfully pulled Docker image from IPFS:
    docker.local:5000/ciqmw4mig2uwaygddjlutoywq43udutvdmuxkcxvetsjp2mjdde27wi
  • Run image pulled from IPFS:

    $ docker run docker.local:5000/ciqmw4mig2uwaygddjlutoywq43udutvdmuxkcxvetsjp2mjdde27wi
    hello world
  • Retag Docker image:

    $ docker tag docker.local:5000/ciqmw4mig2uwaygddjlutoywq43udutvdmuxkcxvetsjp2mjdde27wi example/helloworld:latest
  • We can also pull the image using docker pull:

    • First run the IPDR server in a seperate terminal:

      $ ipdr server -p 5000
      INFO[0000] [registry/server] listening on [::]:5000
    • Then convert the IPFS hash to a valid format docker allows:

      $ ipdr convert QmYMg6WAuvF5i5yFmjT8KkqewZ5Ngh4U9Mp1bGfdjraFVk --format=docker
      
      ciqjjwaeoszdgcaasxmlhjuqnhbctgwijqz64w564lrzeyjezcvbj4y
    • Now we can docker pull the image from IPFS:

      $ docker pull docker.local:5000/ciqjjwaeoszdgcaasxmlhjuqnhbctgwijqz64w564lrzeyjezcvbj4y
      Using default tag: latest
      latest: Pulling from ciqjjwaeoszdgcaasxmlhjuqnhbctgwijqz64w564lrzeyjezcvbj4y
      Digest: sha256:6b787c9e04c2038d4b3cb0392417abdddfcfd88e10005d970fc751cdcfd6d895
      Status: Downloaded newer image for docker.local:5000/ciqjjwaeoszdgcaasxmlhjuqnhbctgwijqz64w564lrzeyjezcvbj4y:latest

      Test run:

      $ docker run docker.local:5000/ciqjjwaeoszdgcaasxmlhjuqnhbctgwijqz64w564lrzeyjezcvbj4y
      hello world

TLDR; example

# build Docker image
docker build -t example/helloworld .

# push to IPFS
IPFS_HASH="$(ipdr push example/helloworld --silent)"

# pull from IPFS
REPO_TAG=$(ipdr pull "$IPFS_HASH" --silent)

# run image pulled from IPFS
docker run "$REPO_TAG"

CLI

$ ipdr --help

The command-line interface for the InterPlanetary Docker Registry.
More info: https://github.com/ipdr/ipdr

Usage:
  ipdr [flags]
  ipdr [command]

Available Commands:
  convert     Convert a hash to IPFS format or Docker registry format
  help        Help about any command
  pull        Pull image from the IPFS-backed Docker registry
  push        Push image to IPFS-backed Docker registry
  server      Start IPFS-backed Docker registry server

Flags:
  -h, --help   help for ipdr

Use "ipdr [command] --help" for more information about a command.

IPNS

An example of using IPNS to resolve image tag names.

  1. First start local server:
ipdr server -p 5000
  1. Tag the image:
docker pull hello-world
docker tag hello-world docker.local:5000/hello-world
  1. Push to local registry:
docker push --quiet docker.local:5000/hello-world

CID mappings live under ~/.ipdr

$ tree ~/.ipdr/
/home/username/.ipdr/
└── cids
    └── hello-world
        └── latest
  1. Add cids directory to IPFS:
$ ipfs add -r ~/.ipdr/cids/ --quieter
QmVtjwa3kdFJHce2wnFuygaCHdSPXraBd4FRSEZKjqZWQp
  1. Set _dnslink TXT record on the domain to point to the directory IPFS hash:
dnslink=/ipfs/QmVtjwa3kdFJHce2wnFuygaCHdSPXraBd4FRSEZKjqZWQp
  1. Verify DNS changes:
$ dig _dnslink.example.com -t TXT +short
"dnslink=/ipfs/QmVtjwa3kdFJHce2wnFuygaCHdSPXraBd4FRSEZKjqZWQp"
  1. Re-run server, now with domain as resolver:
$ ipdr server --cid-resolver=example.com
  1. Now we can run ipdr dig to get CID using repo tag name!
$ ipdr dig hello-world:latest
bafybeiakvswzlopeu573372p5xry47tkc2hhcg5q5rulmbfrnkecrbnt3y

Note: if nothing is returned, then make sure the IPFS gateway is correct.

  1. Next pull and the docker image from IPFS using the resolved CID formatted for docker:
docker pull docker.local:5000/bafybeiakvswzlopeu573372p5xry47tkc2hhcg5q5rulmbfrnkecrbnt3y
docker run docker.local:5000/bafybeiakvswzlopeu573372p5xry47tkc2hhcg5q5rulmbfrnkecrbnt3y

Test

make test

FAQ

  • Q: How do I configure the local registry host or port that IPDR uses when pushing or pulling Docker images?

    • A: Use the --docker-registry-host flag, eg. --docker-registry-host docker.for.mac.local:5000
  • Q: How do I configure the IPFS host that IPDR uses for pushing Docker images?

    • A: Use the --ipfs-host flag, eg. --ipfs-host 127.0.0.1:5001
  • Q: How do I configure the IPFS gateway that IPDR uses for pulling Docker images?

    • A: Use the --ipfs-gateway flag, eg. --ipfs-gateway https://ipfs.io
  • Q: How can I configure the port for the IPDR registry server?

    • A: Use the --port flag, eg. --port 5000
  • Q: How do I setup HTTPS/TLS on the IPDR registry server?

    • A: Use the --tlsKeyPath and --tlsCertPath flag, eg. --tlsKeyPath path/server.key --tlsCertPath path/server.crt
  • Q: How do I get docker.local to work?

    • A: Make sure to add 127.0.0.1 docker.local to /etc/hosts. Optionally, you may use local.ipdr.io which resolves to 127.0.0.1

Contributing

Pull requests are welcome!

For contributions please create a new branch and submit a pull request for review.

Many thanks to @qiangli and all the contributors that made this package better.

Social

Resources

License

MIT

 相关资料
  • IPFS 是分布式文件系统,寻求连接所有计算机设备的相同文件系统。在某些方面,这很类似于原始的 Web 目标,但是 IPFS 最终会更像单个比特流群交换的 git 对象。 IPFS = InterPlanetary File System IPFS 云成为一个新的、重要的网络子系统,如果构建得当,可以完善或者替换 HTTP,或者更多。 IPFS 结合了 Git,BitTorrent,Kademli

  • gomobile-ipfs This repo aims to provide packages for Android, iOS and React-Native thatallow one to run and use an IPFS node on mobile devices. It is also a placeto discuss the constraints of running

  • 《IPFS与Filecoin 从入门到精通》 在接触 IPFS 之后,对这种可以本质上改变网络数据的分发机制的协议非常感兴趣,但由于目前国内并没有比较深入分析 IPFS 的书籍,而一些资料因为英文的缘故在一定程度上也为不少 IPFS 爱好者带来了一些学习上的困扰,不仅为了加快扩散 IPFS 爱好者的国内群体,决定以开源的形式完成这本《IPFS与Filecoin 从入门到精通》的书籍。 写作进度 开

  • ipfs-deploy Upload static website to IPFS pinning services and optionally update DNS. The goal of ipfs-deploy is to make it as easy as possible to deploy a staticwebsite to IPFS. Install Usage API Con

  • IPFS-Chat Real-time, secure, peer-to-peer messaging using IPFS pubsub. Allows in-chat file/directory sharing and private messaging. Works over both internet and LAN. Built-in NAT-traversal using IPFS

  • IPFS in Ethereum Smart Contracts This is a simple blog application that is a proof of concept of connecting Ethereum's smart contracts to JSON database stored on IPFS. The communication is based on Or