<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-to-get-a-shell-in-a-kubernetes-pod-rd6eztxj0" -->

---
title: How to get a shell in a Kubernetes Pod | daily.dev
description: A step-by-step walkthrough on accessing a shell inside a running Docker container using docker exec, then extending the same approach to a Kubernetes pod using...
canonical: https://daily.dev/posts/how-to-get-a-shell-in-a-kubernetes-pod-rd6eztxj0
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How to get a shell in a Kubernetes Pod | daily.dev
og:description: A step-by-step walkthrough on accessing a shell inside a running Docker container using docker exec, then extending the same approach to a Kubernetes pod using...
og:url: https://daily.dev/posts/how-to-get-a-shell-in-a-kubernetes-pod-rd6eztxj0
og:image: https://api.daily.dev/og/posts/rd6eZTxJ0.png
og:image:alt: How to get a shell in a Kubernetes Pod
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to get a shell in a Kubernetes Pod

**[Teleport](https://daily.dev/sources/teleport)** · 10 min read · 0 upvotes · 0 comments

## Summary

A step-by-step walkthrough on accessing a shell inside a running Docker container using docker exec, then extending the same approach to a Kubernetes pod using kubectl exec. Covers building a sample Flask app image, deploying it to Kubernetes via minikube, debugging by installing missing packages, and briefly touches on securing shell access with RBAC. Ends with a mention of Teleport for monitoring and securing Kubernetes shell access.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://goteleport.com/blog/get-a-shell-into-kubernetes-pod>

## Questions this post answers

### How do I get a shell into a running Kubernetes pod?

Run kubectl exec --stdin --tty <pod-name> -- bash, which binds a pseudo-TTY and routes terminal input to the container's standard input. This is similar to Docker's docker exec -it <container> bash. Once inside, you can run commands like ls, apt update, or apt install to debug or install missing packages in the container.

_daily.dev surfaces practical Kubernetes debugging workflows for engineers troubleshooting pods in production._

### How do I open a shell in a running Docker container?

Use docker exec -it <container_name_or_id> bash, which allocates a pseudo-TTY (-t) and creates an interactive session (-i) bound to the container's standard input. First find the container ID or name with docker ps -a, then run the exec command to enter the container's working directory and run debugging commands like ps aux or wc -l.

_developers debugging containerized apps can find more Docker workflow guides on daily.dev._

## Similar posts on daily.dev

- [Kubernetes from Scratch — Part 5: Deployments, ReplicaSets & Services](https://daily.dev/posts/kubernetes-from-scratch-part-5-deployments-replicasets-services-3qaxwmciz) · Medium · 0 upvotes · 0 comments
- [Kubernetes for developers: a complete beginner's guide](https://daily.dev/posts/kubernetes-for-developers-a-complete-beginner-s-guide-e5m8idnmp) · Flavio Copes · 2 upvotes · 0 comments
- [Debugging with Ephemeral Containers](https://daily.dev/posts/debugging-with-ephemeral-containers-1twwwagfl) · Percona Blog · 0 upvotes · 0 comments
- [A Beginner's Guide to Kubernetes](https://daily.dev/posts/a-beginner-s-guide-to-kubernetes-ucyxczyo1) · MetalBear · 0 upvotes · 0 comments
- [Building and Deploying a Containerized Application on Amazon EKS Using Kubernetes](https://daily.dev/posts/building-and-deploying-a-containerized-application-on-amazon-eks-using-kubernetes-io93nnptw) · Medium · 0 upvotes · 0 comments

---

Tags: [#kubernetes](https://daily.dev/tags/kubernetes), [#docker](https://daily.dev/tags/docker)

[View this post on daily.dev](https://daily.dev/posts/how-to-get-a-shell-in-a-kubernetes-pod-rd6eztxj0)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How to get a shell in a Kubernetes Pod","url":"https://daily.dev/posts/how-to-get-a-shell-in-a-kubernetes-pod-rd6eztxj0","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-to-get-a-shell-in-a-kubernetes-pod-rd6eztxj0"},"datePublished":"2026-08-23T12:22:06.813Z","dateModified":"2026-08-23T12:44:18.515Z","description":"A step-by-step walkthrough on accessing a shell inside a running Docker container using docker exec, then extending the same approach to a Kubernetes pod using...","image":"https://media.daily.dev/image/upload/s--1KxV4ohY--/f_auto/v1722860400/public/Placeholder%2007","thumbnailUrl":"https://media.daily.dev/image/upload/s--1KxV4ohY--/f_auto/v1722860400/public/Placeholder%2007","isAccessibleForFree":true,"articleSection":"Teleport","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Teleport","logo":"https://media.daily.dev/image/upload/s--Dw-Bbw6O--/c_limit,w_256/f_auto,q_auto/v1787487494/logos/teleport?_a=BAMAMicg0","url":"https://daily.dev/sources/teleport"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-to-get-a-shell-in-a-kubernetes-pod-rd6eztxj0","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"kubernetes,docker","timeRequired":"PT10M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Teleport","item":"https://daily.dev/sources/teleport"},{"@type":"ListItem","position":3,"name":"How to get a shell in a Kubernetes Pod"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-to-get-a-shell-in-a-kubernetes-pod-rd6eztxj0#faq","mainEntity":[{"@type":"Question","name":"How do I get a shell into a running Kubernetes pod?","acceptedAnswer":{"@type":"Answer","text":"Run kubectl exec --stdin --tty <pod-name> -- bash, which binds a pseudo-TTY and routes terminal input to the container's standard input. This is similar to Docker's docker exec -it <container> bash. Once inside, you can run commands like ls, apt update, or apt install to debug or install missing packages in the container. daily.dev surfaces practical Kubernetes debugging workflows for engineers troubleshooting pods in production."}},{"@type":"Question","name":"How do I open a shell in a running Docker container?","acceptedAnswer":{"@type":"Answer","text":"Use docker exec -it <container_name_or_id> bash, which allocates a pseudo-TTY (-t) and creates an interactive session (-i) bound to the container's standard input. First find the container ID or name with docker ps -a, then run the exec command to enter the container's working directory and run debugging commands like ps aux or wc -l. developers debugging containerized apps can find more Docker workflow guides on daily.dev."}}]}
```

