- Yair Mark
Today I had to modify a file in a running container to debug why something was breaking.
Normally this is a 2 minute process, this ended up being an ordeal:
- Exec into the container:
kubectl exec -it myContainer -n myNamespace -- bash
- Locate the file
- No command found for vim
- Ok not super unusual in lightweight containers
- Surely there's vi! Even ancient Unix distros have it:
- No command found for vi
- Hmm 🤔 emacs
- No :'(
- Ok let's see what
- Ok nano it is
Command not found, unknown error
- Doh, this container is foobar!
- Turns out there is no nano... or any editor for that matter anywhere on this container 🙃
- Ok no editor... I can't install one as this pod is running in a locked down environment...
- Fine let's dump the file on the host
- Edit the file
- Copy back:
kubectl cp myAwesomeFile namespaceOfPod/myPodName:/awesome/file/location
- Done - phew 🍻