You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+79-76Lines changed: 79 additions & 76 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ image2ipfs works only with images prduced docker >= 1.10. On the bright side, al
9
9
image2ipfs takes an image archive produced using `docker save`.
10
10
The archive is extracted to a temp location then processed a bit. Finally, it is added to IPFS using `ipfs add -r`
11
11
(you need to have the ipfs binary in your `PATH`). For a simple busybox image
12
-
image2ipfs will produce a work dir like this:
12
+
image2ipfs will produce something like this:
13
13
```
14
14
busybox
15
15
├── blobs
@@ -23,11 +23,10 @@ busybox
23
23
_v1 Manifests are not supported starting with version 0.0.6_
24
24
But how do you get from something like QmQSF1oN4TXeU2kRvmjerEs62ZYfKPyRCqPvW1XTTc4fLS to a working `docker pull busybox`?
25
25
26
-
The answer is simple: using url rewriting. In the `registry/` subdirectory of the project
27
-
there is a trivial Go application that speaks the Registry v2 protocol but instead of serving the blobs and manifests it redirects
26
+
The answer is simple: using url rewriting.There is a trivial Go application that speaks the Registry v2 protocol but instead of serving the blobs and manifests it redirects
28
27
to an IPFS gateway of your choice.
29
28
30
-
When pulling REPO:latest (with REPO=busybox in this example), Docker daemon will issue these requests:
29
+
When pulling REPO:latest (with REPO=busybox in this example), Docker daemon will issue (roughly) these requests:
31
30
```
32
31
GET /v2/
33
32
GET /v2/REPO/manifest/latest
@@ -36,7 +35,7 @@ GET /v2/REPO/blobs/sha256:193bda8d9ac77416619eb556391a9c5447adb2abf12aab515d1b0c
36
35
GET /v2/REPO/blobs/sha256:a1b1b81d3d1afdb8fe119b002318c12c20934713b9754a40f702adb18a2540b9
37
36
```
38
37
39
-
All the Go app does is produce IPFS links to a an IPFS gateway and redirect docker there:
38
+
The Go app serves redirects to an IPFS gateway like so:
40
39
```
41
40
GET /ipfs/HASH/manifest/latest
42
41
GET /ipfs/HASH/blobs/sha256:47bcc53f74dc94b1920f0b34f6036096526296767650f223433fe65c35f149eb
@@ -48,21 +47,12 @@ GET /ipfs/HASH/blobs/sha256:a1b1b81d3d1afdb8fe119b002318c12c20934713b9754a40f702
48
47
# Installation
49
48
```bash
50
49
$ git clone https://github.com/jvassev/image2ipfs
51
-
$ cd image2ipfs
52
50
53
51
# this will install a python command so pyenv or virtualenv is recommended rather than sudo
54
52
$ make install
55
53
56
-
$ image2ipfs -v
57
-
0.0.6
58
-
```
59
-
60
-
You can also install using pip
61
-
```bash
62
-
$ pip install image2ipfs
63
-
64
-
$ image2ipfs -v
65
-
0.0.6
54
+
$ image2ipfs --version
55
+
0.1.0
66
56
```
67
57
68
58
# Running the registry
@@ -72,18 +62,58 @@ You can pull the official image from dockerhub. This example assumes the gateway
72
62
docker run -td --name ipfs-registry -e IPFS_GATEWAY=http://localhost:8080 --net host jvassev/ipfs-registry
73
63
```
74
64
75
-
Or build from source:
65
+
Or build from source and skip Docker:
76
66
```bash
77
-
# build image locally
78
-
make build-image
67
+
$ make install
68
+
69
+
$ image2ipfs server
70
+
2019/03/12 15:43:58 Using IPFS gateway http://127.0.0.1:8080
71
+
2019/03/12 15:43:58 Serving on :5000
72
+
```
73
+
74
+
# Synopsis
75
+
76
+
The client and server live in the same binary. You can find prebuilt releases for Linux, Mac and Windows on the Releases page. The command flags are compatible with the legacy Python version.
--help Show context-sensitive help (also try --help-long and --help-man).
83
+
--version Show application version.
84
+
-r, --registry="http://localhost:5000"
85
+
Registry to use when generating pull URL
86
+
-n, --no-add Don`t add to IPFS, just print directory
87
+
-q, --quiet Produce less output - just the final pullable image name
88
+
-d, --debug Leave workdir intact (useful for debugging)
89
+
-i, --input="-" Docker image archive to process, defaults to stdin. Use - to explicitly set stdin
90
+
91
+
Commands:
92
+
help [<command>...]
93
+
Show help.
94
+
95
+
96
+
client [<flags>]
97
+
Populate IPFS node with image data
98
+
99
+
-r, --registry="http://localhost:5000"
100
+
Registry to use when generating pull URL
101
+
-n, --no-add Don`t add to IPFS, just print directory
102
+
-q, --quiet Produce less output - just the final pullable image name
103
+
-d, --debug Leave workdir intact (useful for debugging)
104
+
-i, --input="-" Docker image archive to process, defaults to stdin. Use - to explicitly set stdin
105
+
106
+
server [<flags>]
107
+
Run an IFPS-backed registry
108
+
109
+
--gateway="http://127.0.0.1:8080"
110
+
IPFS gateway. It must be reachable by pulling clients
111
+
--addr=":5000" Listen address.
82
112
```
83
113
84
114
# Configure Docker
85
115
86
-
As usual add `--insecure-registry localhost:5000` to your docker daemon args
116
+
As usual add `--insecure-registry localhost:5000` to your docker daemon args. You need to put the `image2ipfs server` behind a reverse proxy if you want to do proper TLS termination.
87
117
88
118
# Demo
89
119
Assuming you have completed the steps above, let's publish a centos:7 image to IPFS!
<missing> 7 months ago /bin/sh -c #(nop) MAINTAINER The CentOS Proje 0 B
158
178
```
159
179
160
-
Depending on how you have started the ipfs-registry the docker daemon will be redirected to an IPFS gateway of your choice. By default the registry
180
+
Depending on how you have started the image2ipfs the docker daemon will be redirected to an IPFS gateway of your choice. By default the registry
161
181
will redirect to the ipfs daemon running locally (http://localhost:8080).
162
182
163
-
But what is this "Dockerized hash ciqn5zu57ciucp3gw2hwxymuwz3tgjlvfdfwg3xhwx456y4xxydkhmq" in the output?
183
+
But what is this "dockerized hash ciqnqalrqxnqzubb2jllburc4e6wt2j7crjx2nxsdfbiw4sceq367lq" in the output?
164
184
Docker requires image names to be all lowercase which doesn't play nicely with base58-encoded binary. A dockerized IPFS hash
165
-
is just a base-32 of the same binary value. This is the reason why the ipfs-registry is not a simple nginx+rewrite rules: you need
166
-
to do base-32 to base-58 conversions. If you see a string starting with `ciq` that's probably a dockerized ipfs hash.
167
-
(OK, you can also do this with nginx_lua)
185
+
is just a base-32 of the same binary value. If you see a string starting with `ciq..` that's probably a dockerized IPFS hash.
168
186
169
187
In automated scenarios you'd probably want to run image2ipfs like this:
170
188
```bash
171
189
172
190
# build whatever images
173
191
$ docker built -t $TAG ...
174
-
$ docker save $TAG| image2ipfs -q -r my-gateway.local:9090 | tee pull-url.txt
175
-
my-gateway.local:9090/ciq..../centos
192
+
193
+
# save the resulting image name
194
+
$ docker save $TAG| image2ipfs -q -r my-gateway.local:8080 > pull-url.txt
176
195
```
177
196
178
197
`-r my-gateway.local` instructs image2ipfs what pull url to produce. In a CI/CD you can distribute this generated url to downstream jobs that need to pull it.
@@ -183,23 +202,6 @@ Not sure. It would be great if an IPFS gateway could speak the Registry v2 proto
183
202
184
203
The Dockerized hash can be shortened a bit if base-36 is used instead of base-32/hex.
0 commit comments