The latest version of Kubernetes does not support Docker as a container runtime anymore. That is why many Kubernetes administrators have migrated their cluster’s container runtime from docker to another container runtime like containerd or cri-o. Or they will do that soon.

References

  • https://gist.github.com/mamiu/4944e10305bc1c3af84946b33237b0e9

Old: entering a Container as root with Docker

Most containers that run on Kubernetes clusters do not run as root. But what, if you want to test a container and for that, you want to install and test some software manually before you create a new container image? With Docker that was easy. Just enter the container as root (id=0) and do with the container, whatever you want to do:

docker exec -it --rm -u 0 <container-id> bash

Now, that the containers are no Docker containers anymore, this is not possible anymore.

New: entering a Container as root with runc

However, you can runc to enter the container as root. Say, you want to enter a shell as root user in the container running on my-pod on my-namespace. First, you need to calculate the container ID. With that information you can enter the container using runc like follows:

# INPUT
N=my-namespace

# CALCULATE
POD=$(kubectl -n $N get pod | tail -1 | awk '{print $1}') 
# or define static POD, if needed: 
# POD=my-pod
CONTAINER=$(kubectl -n $N get pod $POD -o jsonpath="{.status.containerStatuses[].containerID}" | sed 's/.*\/\///')

# RUN SHELL AS ROOT
sudo runc --root /run/containerd/runc/k8s.io/ exec -t -u 0 $CONTAINER sh

That’s it! You even do not need to install runc, since runc is part of the installation package if you have installed containerd (and I guess, also with cri-o…).

P.S.: if you still need to migrate your Kubernetes cluster from Docker container runtime to containerd runtime, you might be interested in this blog post:

Migrate Kubernetes Runtime from Docker to containerd

47 comments

  1. 2 things here. 1) wait until you have a container ID your container must be in running state or there will be no ID yet. 2) You must run the „runc“ command on the worker node that your container is running on in case you have a K8s Cluster.

  2. Hi i think that i saw you visited my web site thus i came to Return the favore I am attempting to find things to improve my web siteI suppose its ok to use some of your ideas

  3. I loved as much as youll receive carried out right here The sketch is tasteful your authored material stylish nonetheless you command get bought an nervousness over that you wish be delivering the following unwell unquestionably come more formerly again since exactly the same nearly a lot often inside case you shield this hike

  4. My brother recommended I might like this web site He was totally right This post actually made my day You cannt imagine just how much time I had spent for this information Thanks

  5. certainly like your website but you need to take a look at the spelling on quite a few of your posts Many of them are rife with spelling problems and I find it very troublesome to inform the reality nevertheless I will definitely come back again

  6. Somebody essentially help to make significantly articles Id state This is the first time I frequented your web page and up to now I surprised with the research you made to make this actual post incredible Fantastic job

  7. I loved as much as youll receive carried out right here The sketch is attractive your authored material stylish nonetheless you command get bought an nervousness over that you wish be delivering the following unwell unquestionably come more formerly again as exactly the same nearly a lot often inside case you shield this hike

  8. I loved as much as youll receive carried out right here The sketch is attractive your authored material stylish nonetheless you command get bought an nervousness over that you wish be delivering the following unwell unquestionably come more formerly again as exactly the same nearly a lot often inside case you shield this hike

  9. certainly like your website but you need to take a look at the spelling on quite a few of your posts Many of them are rife with spelling problems and I find it very troublesome to inform the reality nevertheless I will definitely come back again

  10. Thanks I have recently been looking for info about this subject for a while and yours is the greatest I have discovered so far However what in regards to the bottom line Are you certain in regards to the supply

  11. The Beatles – ??????????? ?????????? ???-??????, ?????????????? ? 1960 ???? ? ?????????. ?? ?????? ????? ???????? ????? ? ??????? ???????? ??????? ?? ??????? ????????. ????? ?? ?????? ?????: „Hey Jude“, „Let It Be“, „Yesterday“, „Come Together“, „Here Comes the Sun“, „A Day in the Life“, „Something“, „Eleanor Rigby“ ? ?????? ??????. ?? ?????????? ?????????? ?????????????, ???????? ??????? ? ?????????????? ? ?????, ??? ??????? ?? ????? ?? ????? ??????????? ????? ? ??????? ??????. ?????? 2024 ???? ??????? ?????? ? ??????? ????????? mp3.

  12. Over the last week I eagerly started following this phenomenal website, they share fabulous content with visitors. The site owner excels at educating customers. I’m excited and hope they keep up their awesome work!

  13. twitch ad blocker chrome twitch adblock twitchadblocker Twitch ad blocker is a helpful tool Twitch adblock firefox stops ads from appearing when you watch live streams on Twitch, it prevents all those annoying ads from showing up in between, So it’s time to install the extension to broadcast live streams in a hassle-free manner.

  14. adblock hulu hulu no ads ad free hulu Hulu ad blocker is a browser extension that helps block advertisements while streaming content on the platform, it prevents ads from playing during TV shows, movies, and series that allow you to watch your favorite programs and shows without any disruptions.

  15. hbo max watch party is a browser extension that lets you watch HBO with friends & family even if you’re far apart. It syncs video playback, group chat, and even video and audio call features. It’s your go-to for long-distance movie with loved ones.

  16. Com esta extensão Teleparty, você pode reunir amigos e familiares em uma noite de cinema virtual e criar um lembrete especial com funções adicionais como bate-papo, chamadas de áudio e vídeo. Esta é a melhor extensão que lhe permite desfrutar de todos os seus últimos programas com os seus amigos e familiares.

  17. Si vous souhaitez regarder un film avec vos proches en même temps, téléchargez le teleparty extension et connectez-vous en même temps. C’est la meilleure extension, où vous avez un Netflix party avec votre famille et vos amis. Alors préparez-vous à passer une soirée virtuelle avec eux.

  18. obviously like your website but you need to test the spelling on quite a few of your posts Several of them are rife with spelling problems and I to find it very troublesome to inform the reality on the other hand Ill certainly come back again

  19. Usually I do not read article on blogs however I would like to say that this writeup very compelled me to take a look at and do so Your writing taste has been amazed me Thanks quite nice post

  20. Its like you read my mind You appear to know so much about this like you wrote the book in it or something I think that you can do with a few pics to drive the message home a little bit but other than that this is fantastic blog A great read Ill certainly be back

  21. obviously like your website but you need to test the spelling on quite a few of your posts Several of them are rife with spelling problems and I to find it very troublesome to inform the reality on the other hand Ill certainly come back again

  22. Somebody essentially help to make significantly articles Id state This is the first time I frequented your web page and up to now I surprised with the research you made to make this actual post incredible Fantastic job

  23. I loved as much as youll receive carried out right here The sketch is tasteful your authored material stylish nonetheless you command get bought an nervousness over that you wish be delivering the following unwell unquestionably come more formerly again since exactly the same nearly a lot often inside case you shield this hike

  24. I was recommended this website by my cousin I am not sure whether this post is written by him as nobody else know such detailed about my trouble You are amazing Thanks

  25. Hi i think that i saw you visited my web site thus i came to Return the favore Im attempting to find things to enhance my siteI suppose its ok to use a few of your ideas

  26. I loved as much as you will receive carried out right here The sketch is tasteful your authored subject matter stylish nonetheless you command get got an edginess over that you wish be delivering the following unwell unquestionably come further formerly again as exactly the same nearly very often inside case you shield this hike

  27. certainly like your website but you need to take a look at the spelling on quite a few of your posts Many of them are rife with spelling problems and I find it very troublesome to inform the reality nevertheless I will definitely come back again

  28. Thank you I have just been searching for information approximately this topic for a while and yours is the best I have found out so far However what in regards to the bottom line Are you certain concerning the supply

  29. certainly like your website but you need to take a look at the spelling on quite a few of your posts Many of them are rife with spelling problems and I find it very troublesome to inform the reality nevertheless I will definitely come back again

Comments

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.