K3s: List Containerd images and containers

Created on 11 Mar 2019  Â·  8Comments  Â·  Source: k3s-io/k3s

Thanks for helping us to improve k3s! We welcome all bug reports. At this stage, we are also looking for help in testing/QAing fixes. Once we've fixed you're issue, we'll ping you in the comments to see if you can verify the fix. We'll give you details on what version can be used to test the fix. Additionally, if you are interested in testing fixes that you didn't report, look for the issues with the status/to-test label. You can pick any of these up for verification. You can delete this message portion of the bug report.

Describe the bug

Using the ctr binary and pointing it to the k3s containerd.sock it doesn't show any resources.

Is there any other way to list any running containers / downloaded images?

To Reproduce
Steps to reproduce the behavior:

  1. Run the K3S server and agent.
  2. sudo ctr -a /run/k3s/containerd/containerd.sock images ls

Expected behavior

Shows a list of all the downloaded images.

Screenshots
If applicable, add screenshots to help explain your problem.

As it can be seen, there are pods running, but no images are showing at the containerd.

Additional context
Add any other context about the problem here.

  • K3S installed with the curl | sh script
  • K3S being run in an AWS EC2 server.

Most helpful comment

You can list the running containers with:

k3s crictl ps

And list the downloaded images with

k3s crictl images

All 8 comments

You can list the running containers with:

k3s crictl ps

And list the downloaded images with

k3s crictl images

As @tcassaert said, the cri-tools (crictl) is included by default, you can run "k3s crictl xxx", here are some examples.

But this issue reminds that we need to add the description of the crictl command in README.md.

$ k3s crictl images
IMAGE                                   TAG                 IMAGE ID            SIZE
docker.io/coredns/coredns               1.3.0               2ee68ed074c6e       12.3MB
docker.io/katacoda/docker-http-server   latest              0d6ee549ae131       2.25MB
docker.io/library/traefik               1.7.9               98768a8bf3fed       19.9MB
docker.io/rancher/klipper-helm          v0.1.2              b8b351c31b0ab       27.1MB
docker.io/rancher/klipper-lb            v0.1.1              4a065d8dfa588       2.71MB
k8s.gcr.io/pause                        3.1                 da86e6ba6ca19       317kB
$
$ k3s crictl ps -a
CONTAINER ID        IMAGE               CREATED              STATE               NAME                 ATTEMPT             POD ID
4f97f3077efa1       4a065d8dfa588       About a minute ago   Running             https                0                   744af145686d7
399ab75962fd1       4a065d8dfa588       About a minute ago   Running             http                 0                   744af145686d7
08ca46f92f977       98768a8bf3fed       About a minute ago   Running             traefik              0                   3a7f5bcdece05
bb4aff46007a5       b8b351c31b0ab       About a minute ago   Exited              helm                 0                   07e8ec42dda57
8a41a9fd2bab8       2ee68ed074c6e       About a minute ago   Running             coredns              0                   ad9c30825e45a
4c9c6fb8b4695       0d6ee549ae131       14 minutes ago       Running             docker-http-server   0                   ae6b8c1748850
$
$ k3s crictl pods
POD ID              CREATED             STATE               NAME                             NAMESPACE          ATTEMPT
744af145686d7       2 minutes ago       Ready               svclb-traefik-54cbdc9d99-wxr8r   kube-system         0
3a7f5bcdece05       2 minutes ago       Ready               traefik-6876857645-r8fx6         kube-system         0
07e8ec42dda57       3 minutes ago       NotReady            helm-install-traefik-5kc9l       kube-system         0
ad9c30825e45a       3 minutes ago       Ready               coredns-7748f7f6df-x29ls         kube-system         0
ae6b8c1748850       15 minutes ago      Ready               http-8654dd748-lhjf5             default          0
$
$ k3s crictl stats
CONTAINER           CPU %               MEM                 DISK                INODES
08ca46f92f977       0.29                11.15MB             53.25kB             15
399ab75962fd1       0.00                905.2kB             24.58kB             9
4c9c6fb8b4695       0.01                1.38MB              40.96kB             12
4f97f3077efa1       0.00                831.5kB             24.58kB             9
8a41a9fd2bab8       0.21                7.979MB             45.06kB             13
$

Any idea what could cause this error ?

➜  ~ k3s crictl ps 
FATA[2019-03-12T10:49:04.198638576-03:00] failed to connect: failed to connect: context deadline exceeded 

Any idea what could cause this error ?

➜  ~ k3s crictl ps 
FATA[2019-03-12T10:49:04.198638576-03:00] failed to connect: failed to connect: context deadline exceeded 

Ops, worked with sudo.

Looks like the question has been answered, so closing

I'll put this here just in case anyone's looking for it like I was.
k3s crictl is great but if you really want to use the ctr binary, try to specify the namespace like this:

sudo ctr -n k8s.io -a /run/k3s/containerd/containerd.sock images ls

I was also able to import a local image this way.

@uudens This is exactly what I'm looking for.

Can you please ellaborate a little bit more on how the local images appearing in

docker images

be accessed using sudo k3s crictl images?

To import a local docker image in k3s, do the following

Export the image to a tar file
sudo docker save custom-image > custom-image.tar

Import image using containerd runtime
sudo ctr -n k8s.io -a /run/k3s/containerd/containerd.sock image import custom-image.tar

Was this page helpful?
0 / 5 - 0 ratings