containerd / nerdctl

contaiNERD CTL - Docker-compatible CLI for containerd, with support for Compose, Rootless, eStargz, OCIcrypt, IPFS, ...
Apache License 2.0
7.72k stars 574 forks source link

The `--runtime` option of `container create` is ignored #2409

Open antoineco opened 12 months ago

antoineco commented 12 months ago

Description

Unlike ctr — which I used here as a reference — nerdctl does not honor the --runtime flag while creating a container.

Steps to reproduce the issue

  1. Create a container with nerdctl, and set the --runtime flag:
    $ sudo nerdctl container create --runtime com.example.sample.v1 docker.io/library/busybox:1.36
    aa4ca0d0622a5d44abe24b39e7837f65e900ebfec832d7435cc0d5f39a573b14
  2. Create a similar container with ctr, and set the --runtime flag:
    $ sudo ctr container create --runtime com.example.sample.v1 docker.io/library/busybox:1.36 shim-test
  3. Observe that ctr created the container with the expected runtime, but nerdctl didn't:
    $ sudo ctr container ls
    CONTAINER    IMAGE                             RUNTIME
    aa4ca0d06    docker.io/library/busybox:1.36    io.containerd.runc.v2  <-- nerdctl
    shim-test    docker.io/library/busybox:1.36    com.example.sample.v1  <-- ctr

Describe the results you received and expected

nerdctl container create --runtime com.example.sample.v1 creates a container with the com.example.sample.v1 runtime. Instead, it created a container with the default runtime, io.containerd.runc.v2.

What version of nerdctl are you using?

Client:
 Version:       v1.5.0
 OS/Arch:       linux/amd64
 Git commit:    b33a58f288bc42351404a016e694190b897cd252
 buildctl:
  Version:      v0.12.0
  GitCommit:    18fc875d9bfd6e065cd8211abc639434ba65aa56

Server:
 containerd:
  Version:      v1.7.3
  GitCommit:    7880925980b188f4c97b462f709d0db8e8962aff
 runc:
  Version:      1.1.8
  GitCommit:    v1.1.8-0-g82f18fe0

(The issue already occurred with v1.4.0)

Are you using a variant of nerdctl? (e.g., Rancher Desktop)

None

Host information

Client:
 Namespace:     default
 Debug Mode:    false

Server:
 Server Version: v1.7.3
 Storage Driver: overlayfs
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Log: fluentd journald json-file syslog
  Storage: native overlayfs
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.15.90.1-microsoft-standard-WSL2
 Operating System: Ubuntu 23.04
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 7.65GiB
 Name: calavera
 ID: 6431bf05-39a9-4eae-a5ae-e514bbfc8316
antoineco commented 12 months ago

The culprit was actually simple to find. Shims must follow the naming convention io.containerd.*:

https://github.com/containerd/nerdctl/blob/2eeffe086961098f2e040f784c1707a1adc1cdb4/pkg/cmd/container/run_runtime.go#L41-L43

yankay commented 11 months ago

HI @antoineco

When I try to investigate the issue and run with docker.

root@kay200:~# docker container create --runtime com.example.sample.v1 docker.m.daocloud.io/nginx:alpine
Error response from daemon: Unknown runtime specified com.example.sample.v1

So Does the expected result need to be the same with docker :-)

antoineco commented 11 months ago

I guess that's fine for me. If shims for containerd need to follow a certain naming convention I'll follow that convention.

AkihiroSuda commented 11 months ago

This is still a bug

zhangguanzhang commented 3 months ago

any update?