Skip to content

Commit

Permalink
refactor(container): refactor cp flag
Browse files Browse the repository at this point in the history
Signed-off-by: Yuchao.Li <mimelyc@gmail.com>
  • Loading branch information
MimeLyc committed Feb 2, 2023
1 parent b0701ba commit 8f0f420
Show file tree
Hide file tree
Showing 31 changed files with 477 additions and 359 deletions.
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ windows_task:
matrix:
- name: "Windows/containerd-1.6"
env:
ctrdVersion: 1.6.12
ctrdVersion: 1.6.16
env:
CGO_ENABLED: 0
build_script:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ghcr-image-build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@v3.3.0
uses: docker/build-push-action@v4.0.0
with:
context: .
platforms: linux/amd64,linux/arm64
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ jobs:
# ubuntu-20.04: cgroup v1, ubuntu-22.04: cgroup v2
include:
- ubuntu: 20.04
containerd: v1.5.13
containerd: v1.5.17
- ubuntu: 20.04
containerd: v1.6.12
containerd: v1.6.16
- ubuntu: 22.04
containerd: v1.6.12
containerd: v1.6.16
- ubuntu: 22.04
containerd: main
env:
Expand Down Expand Up @@ -105,11 +105,11 @@ jobs:
# ubuntu-22.04: cgroup v1, ubuntu-22.04: cgroup v2
include:
- ubuntu: 20.04
containerd: v1.5.13
containerd: v1.5.17
- ubuntu: 20.04
containerd: v1.6.12
containerd: v1.6.16
- ubuntu: 22.04
containerd: v1.6.12
containerd: v1.6.16
- ubuntu: 22.04
containerd: main
env:
Expand Down
15 changes: 8 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
# TODO: verify commit hash

# Basic deps
ARG CONTAINERD_VERSION=v1.6.12
ARG CONTAINERD_VERSION=v1.6.16
ARG RUNC_VERSION=v1.1.4
ARG CNI_PLUGINS_VERSION=v1.1.1
ARG CNI_PLUGINS_VERSION=v1.2.0

# Extra deps: Build
ARG BUILDKIT_VERSION=v0.11.0
ARG BUILDKIT_VERSION=v0.11.2
# Extra deps: Lazy-pulling
ARG STARGZ_SNAPSHOTTER_VERSION=v0.14.1
# Extra deps: Nydus Lazy-pulling
ARG NYDUS_VERSION=v2.1.1
ARG NYDUS_VERSION=v2.1.3
# Extra deps: Encryption
ARG IMGCRYPT_VERSION=v1.1.7
# Extra deps: Rootless
Expand All @@ -39,7 +39,7 @@ ARG BYPASS4NETNS_VERSION=v0.3.0
ARG FUSE_OVERLAYFS_VERSION=v1.10
ARG CONTAINERD_FUSE_OVERLAYFS_VERSION=v1.0.5
# Extra deps: IPFS
ARG KUBO_VERSION=v0.17.0
ARG KUBO_VERSION=v0.18.0
# Extra deps: Init
ARG TINI_VERSION=v0.19.0
# Extra deps: Debug
Expand All @@ -49,7 +49,7 @@ ARG BUILDG_VERSION=v0.4.1
ARG GO_VERSION=1.19
ARG UBUNTU_VERSION=22.04
ARG CONTAINERIZED_SYSTEMD_VERSION=v0.1.1
ARG GOTESTSUM_VERSION=v1.8.2
ARG GOTESTSUM_VERSION=v1.9.0

FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-bullseye AS build-base-debian
# libbtrfs: for containerd
Expand Down Expand Up @@ -248,7 +248,8 @@ COPY --from=out-full / /usr/local/
RUN perl -pi -e 's/multi-user.target/docker-entrypoint.target/g' /usr/local/lib/systemd/system/*.service && \
systemctl enable containerd buildkit stargz-snapshotter && \
mkdir -p /etc/bash_completion.d && \
nerdctl completion bash >/etc/bash_completion.d/nerdctl
nerdctl completion bash >/etc/bash_completion.d/nerdctl && \
mkdir -p -m 0755 /etc/cni
COPY ./Dockerfile.d/etc_containerd_config.toml /etc/containerd/config.toml
COPY ./Dockerfile.d/etc_buildkit_buildkitd.toml /etc/buildkit/buildkitd.toml
VOLUME /var/lib/containerd
Expand Down
2 changes: 0 additions & 2 deletions Dockerfile.d/SHA256SUMS.d/buildkit-v0.11.0

This file was deleted.

2 changes: 2 additions & 0 deletions Dockerfile.d/SHA256SUMS.d/buildkit-v0.11.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
6d0fe3f1ec2dce4ed2a5c9baf05fb279225b3b0e3bbee4092304fe284ca7fc47 buildkit-v0.11.2.linux-amd64.tar.gz
8a8c2274852ea4bac6ccf1862a46679e93c013de8c5c0434a3040bab2e0a42a7 buildkit-v0.11.2.linux-arm64.tar.gz
2 changes: 0 additions & 2 deletions Dockerfile.d/SHA256SUMS.d/cni-plugins-v1.1.1

This file was deleted.

2 changes: 2 additions & 0 deletions Dockerfile.d/SHA256SUMS.d/cni-plugins-v1.2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
f3a841324845ca6bf0d4091b4fc7f97e18a623172158b72fc3fdcdb9d42d2d37 cni-plugins-linux-amd64-v1.2.0.tgz
525e2b62ba92a1b6f3dc9612449a84aa61652e680f7ebf4eff579795fe464b57 cni-plugins-linux-arm64-v1.2.0.tgz
3 changes: 0 additions & 3 deletions Dockerfile.d/SHA256SUMS.d/kubo-v0.17.0

This file was deleted.

3 changes: 3 additions & 0 deletions Dockerfile.d/SHA256SUMS.d/kubo-v0.18.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# From https://github.com/ipfs/kubo/releases
feda3df53d1f9a80afb71518714894d54269fdd2f27eae675a048aa1e7c5b956 kubo_v0.18.0_linux-amd64.tar.gz
416974e3e12d019b72adbe2cc3f13398f281bdd53250d670497c606b423e68fc kubo_v0.18.0_linux-arm64.tar.gz
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,21 @@ To load an image archive (`docker save` format or OCI format) into local Kuberne
# nerdctl --namespace k8s.io load < /path/to/image.tar
```

To read logs (experimental):
```console
# nerdctl --namespace=k8s.io ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
...
e8793b8cca8b registry.k8s.io/coredns/coredns:v1.9.3 "/coredns -conf /etc…" 2 minutes ago Up k8s://kube-system/coredns-787d4945fb-mfx6b/coredns
...

# nerdctl --namespace=k8s.io logs -f e8793b8cca8b
[INFO] plugin/reload: Running configuration SHA512 = 591cf328cccc12bc490481273e738df59329c62c0b729d94e8b61db9961c2fa5f046dd37f1cf888b953814040d180f52594972691cd6ff41be96639138a43908
CoreDNS-1.9.3
linux/amd64, go1.18.2, 45b0a11
...
```

### Rootless mode

To launch rootless containerd:
Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/compose_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func printComposeImages(ctx context.Context, cmd *cobra.Command, containers []co
return err
}

size, err := unpackedImageSize(ctx, sn, image)
size, err := imgutil.UnpackedImageSize(ctx, sn, image)
if err != nil {
return err
}
Expand Down
52 changes: 52 additions & 0 deletions cmd/nerdctl/compose_up_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"fmt"
"runtime"
"testing"

"github.com/containerd/nerdctl/pkg/testutil"
"gotest.tools/v3/icmd"
)

// https://github.com/containerd/nerdctl/issues/1942
func TestComposeUpDetailedError(t *testing.T) {
if runtime.GOOS != "linux" {
t.Skip("FIXME: test does not work on Windows yet (runtime \"io.containerd.runc.v2\" binary not installed \"containerd-shim-runc-v2.exe\": file does not exist)")
}
base := testutil.NewBase(t)
dockerComposeYAML := fmt.Sprintf(`
services:
foo:
image: %s
runtime: invalid
`, testutil.CommonImage)
comp := testutil.NewComposeDir(t, dockerComposeYAML)
defer comp.CleanUp()

c := base.ComposeCmd("-f", comp.YAMLFullPath(), "up", "-d")
expected := icmd.Expected{
ExitCode: 1,
Err: `exec: \"invalid\": executable file not found in $PATH`,
}
if base.Target == testutil.Docker {
expected.Err = `Unknown runtime specified invalid`
}
c.Assert(expected)
}
Loading

0 comments on commit 8f0f420

Please sign in to comment.