DEV Community

Jution Candra Kirana
Jution Candra Kirana

Posted on

Kubernetes: Exec

Let's return to the docker material for a moment. In Docker, you can enter a running container using the docker exec command. Similarly, in Kubernetes, you can enter a container within a pod using the kubectl exec command.

Catatan: Since a pod can have more than one container, you can specify the container you want to enter by using the -c {container_name} option. The full command looks like this:

kubectl exec -it {nama_pod} -c {nama_container} -- /bin/sh
Enter fullscreen mode Exit fullscreen mode

So, if you want to enter the container that was created earlier, the command would be:

kubectl exec -it sample-nginx -- /bin/sh

/ # ls
bin                   home                  proc                  sys
dev                   lib                   root                  tmp
docker-entrypoint.d   media                 run                   usr
docker-entrypoint.sh  mnt                   sbin                  var
etc                   opt                   srv
/ #
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay