Skip to content

Commit 787353c

Browse files
authored
Merge pull request #94 from AkihiroSuda/dev
support ocicrypt
2 parents ce919a8 + 63e459e commit 787353c

6 files changed

Lines changed: 112 additions & 17 deletions

File tree

Dockerfile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ ARG CNI_ISOLATION_VERSION=0.0.3
1111
ARG BUILDKIT_VERSION=0.8.2
1212
# Extra deps: Lazy-pulling
1313
ARG STARGZ_SNAPSHOTTER_VERSION=0.4.1
14+
# Extra deps: Encryption
15+
ARG IMGCRYPT_VERSION=1.1.0
1416
# Extra deps: Rootless
1517
ARG ROOTLESSKIT_VERSION=0.14.0-beta.0
1618
ARG SLIRP4NETNS_VERSION=1.1.9
@@ -67,6 +69,11 @@ ARG STARGZ_SNAPSHOTTER_VERSION
6769
RUN curl -L https://github.com/containerd/stargz-snapshotter/releases/download/v${STARGZ_SNAPSHOTTER_VERSION}/stargz-snapshotter-v${STARGZ_SNAPSHOTTER_VERSION}-linux-${TARGETARCH:-amd64}.tar.gz | tar xzvC /out/bin && \
6870
curl -L -o /out/lib/systemd/system/stargz-snapshotter.service https://raw.githubusercontent.com/containerd/stargz-snapshotter/v${STARGZ_SNAPSHOTTER_VERSION}/script/config/etc/systemd/system/stargz-snapshotter.service && \
6971
echo "- Stargz Snapshotter: v${STARGZ_SNAPSHOTTER_VERSION}" >> /out/share/doc/nerdctl-full/README.md
72+
ARG IMGCRYPT_VERSION
73+
RUN git clone https://github.com/containerd/imgcrypt.git /go/src/github.com/containerd/imgcrypt && \
74+
cd /go/src/github.com/containerd/imgcrypt && \
75+
CGO_ENABLED=0 make && DESTDIR=/out make install && \
76+
echo "- imgcrypt: v${IMGCRYPT_VERSION}" >> /out/share/doc/nerdctl-full/README.md
7077
ARG ROOTLESSKIT_VERSION
7178
RUN curl -L https://github.com/rootless-containers/rootlesskit/releases/download/v${ROOTLESSKIT_VERSION}/rootlesskit-$(uname -m).tar.gz | tar xzvC /out/bin && \
7279
rm -f /out/bin/rootlesskit-docker-proxy && \
@@ -86,9 +93,10 @@ RUN echo "" >> /out/share/doc/nerdctl-full/README.md && \
8693
echo "## License" >> /out/share/doc/nerdctl-full/README.md && \
8794
echo "- bin/slirp4netns: [GNU GENERAL PUBLIC LICENSE, Version 2](https://github.com/rootless-containers/slirp4netns/blob/v${SLIRP4NETNS_VERSION}/COPYING)" >> /out/share/doc/nerdctl-full/README.md && \
8895
echo "- bin/fuse-overlayfs: [GNU GENERAL PUBLIC LICENSE, Version 3](https://github.com/containers/fuse-overlayfs/blob/v${FUSE_OVERLAYFS_VERSION}/COPYING)" >> /out/share/doc/nerdctl-full/README.md && \
89-
echo "- Other files: [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0)" >> /out/share/doc/nerdctl-full/README.md
90-
RUN (cd /out && find ! -type d | sort | xargs sha256sum > /tmp/SHA256SUMS ) && \
91-
mv /tmp/SHA256SUMS /out/share/doc/nerdctl-full/SHA256SUMS
96+
echo "- Other files: [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0)" >> /out/share/doc/nerdctl-full/README.md && \
97+
(cd /out && find ! -type d | sort | xargs sha256sum > /tmp/SHA256SUMS ) && \
98+
mv /tmp/SHA256SUMS /out/share/doc/nerdctl-full/SHA256SUMS && \
99+
chown -R 0:0 /out
92100

93101
FROM scratch AS out-full
94102
COPY --from=build-full /out /

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
[**Download**](https://github.com/AkihiroSuda/nerdctl/releases)
1+
[[⬇️ **Download]**](https://github.com/AkihiroSuda/nerdctl/releases)
2+
[[📖 **Command reference]**](#command-reference)
3+
[[📚 **Additional documents]**](#additional-documents)
24

35
# nerdctl: Docker-compatible CLI for containerd
46

@@ -10,6 +12,8 @@
1012

1113
✅ Supports [lazy-pulling (Stargz)](./docs/stargz.md)
1214

15+
✅ Supports [encrypted images (ocicrypt)](./docs/ocicrypt.md)
16+
1317
## Examples
1418

1519
### Basic usage
@@ -69,19 +73,25 @@ docker run -it --rm --privileged nerdctl
6973

7074
The goal of `nerdctl` is to facilitate experimenting the cutting-edge features of containerd that are not present in Docker.
7175

72-
Such features includes, but not limited to, [lazy-pulling](./docs/stargz.md) and [encryption of images](https://github.com/containerd/imgcrypt).
76+
Such features includes, but not limited to, [lazy-pulling](./docs/stargz.md) and [encryption of images](./docs/ocicrypt.md).
7377

7478
Note that competing with Docker is _not_ the goal of `nerdctl`. Those cutting-edge features are expected to be eventually available in Docker as well.
7579

7680
Also, `nerdctl` might be potentially useful for debugging Kubernetes clusters, but it is not the primary goal.
7781

7882
## Features present in `nerdctl` but not present in Docker
83+
Major:
84+
- [Lazy-pulling using Stargz Snapshotter](./docs/stargz.md): `nerdctl --snapshotter=stargz run` .
85+
- [Running encrypted images using ocicrypt (imgcrypt)](./docs/ocicrypt.md)
86+
87+
Minor:
7988
- Namespacing: `nerdctl --namespace=<NS> ps` .
8089
(NOTE: All Kubernetes containers are in the `k8s.io` containerd namespace regardless to Kubernetes namespaces)
81-
- [Lazy-pulling using Stargz Snapshotter](./docs/stargz.md): `nerdctl --snapshotter=stargz run` .
8290
- Exporting Docker/OCI dual-format archives: `nerdctl save` .
8391
- Importing OCI archives as well as Docker archives: `nerdctl load` .
8492
- Specifying a non-image rootfs: `nerdctl run -it --rootfs <ROOTFS> /bin/sh` . The CLI syntax conforms to Podman convention.
93+
94+
Trivial:
8595
- Inspecting raw OCI config: `nerdctl container inspect --mode=native` .
8696

8797
## Similar tools
@@ -497,3 +507,4 @@ Others:
497507
- [`./docs/registry.md`](./docs/registry.md): Registry authentication (`~/.docker/config.json`)
498508
- [`./docs/rootless.md`](./docs/rootless.md): Rootless mode
499509
- [`./docs/stargz.md`](./docs/stargz.md): Lazy-pulling using Stargz Snapshotter
510+
- [`./docs/ocicrypt.md`](./docs/ocicrypt.md): Running encrypted images

docs/ocicrypt.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# OCIcrypt
2+
3+
4+
See https://github.com/containerd/imgcrypt to learn further information.
5+
6+
## Encryption
7+
8+
See https://github.com/containerd/imgcrypt
9+
10+
## Decryption
11+
12+
### Configuration
13+
Add the following configuration to `/etc/containerd/config.toml` (for rootless `~/.config/containerd/config.toml`):
14+
15+
```toml
16+
version = 2
17+
18+
[stream_processors]
19+
[stream_processors."io.containerd.ocicrypt.decoder.v1.tar.gzip"]
20+
accepts = ["application/vnd.oci.image.layer.v1.tar+gzip+encrypted"]
21+
returns = "application/vnd.oci.image.layer.v1.tar+gzip"
22+
path = "ctd-decoder"
23+
args = ["--decryption-keys-path", "/etc/containerd/ocicrypt/keys"]
24+
[stream_processors."io.containerd.ocicrypt.decoder.v1.tar"]
25+
accepts = ["application/vnd.oci.image.layer.v1.tar+encrypted"]
26+
returns = "application/vnd.oci.image.layer.v1.tar"
27+
path = "ctd-decoder"
28+
args = ["--decryption-keys-path", "/etc/containerd/ocicrypt/keys"]
29+
30+
# NOTE: On rootless, ~/.config/containerd is mounted as /etc/containerd in the namespace.
31+
```
32+
33+
Future version of containerd may have this configuration by default: https://github.com/containerd/containerd/pull/5135
34+
35+
Then, put the private key files to `/etc/containerd/ocicrypt/keys` (for rootless `~/.config/containerd/ocicrypt/keys`).
36+
37+
### nerdctl run
38+
39+
No flag is needed for running encrypted images with `nerdctl run`.
40+
41+
Just run `nerdctl run example.com/encrypted-image`.

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ require (
77
github.com/containerd/console v1.0.1
88
github.com/containerd/containerd v1.5.0-beta.2
99
github.com/containerd/go-cni v1.0.1
10+
github.com/containerd/imgcrypt v1.1.0
1011
github.com/containerd/stargz-snapshotter v0.4.1
1112
github.com/containerd/stargz-snapshotter/estargz v0.4.1
1213
github.com/containerd/typeurl v1.0.1
@@ -32,6 +33,6 @@ require (
3233
github.com/urfave/cli/v2 v2.3.0
3334
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9
3435
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a
35-
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4
36-
gotest.tools/v3 v3.0.2
36+
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c
37+
gotest.tools/v3 v3.0.3
3738
)

0 commit comments

Comments
 (0)