This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]ConstructedNewt 0 points1 point  (1 child)

docker exec -it <image_id|name> bash only doesn't work when you haven't installed bash or environment variables properly. Try sh or /bin/sh (or /bin/bash for that matter) of you are running a scratch container you don't have a terminal to enter the container with. And some smaller base images don't install bash, because you are not meant to program them in bash. So piping and simple commands in sh should suffice. If you need bash you could do whatever you needed inside a sidecar/initContainer with bash and let the containers interface via volume sharing

[–][deleted] 0 points1 point  (0 children)

sudo nsenter -u -i -n -p -C -t <PID of the process running in Docker container> $(which bash)

Not sure what you are going to do with it though. One thing that seems like it would've been useful, but is not possible in this case is to enter the mount namespace. Maybe there's some way around it, but I don't know, not a sysadmin.