In one terminal I have a running container
docker container run --rm -it bash
In another terminal I want to run bin/bash in the same namespace as the running container above. For that to happen I followed these steps:
Grab the PID of the running container
docker inspect --format {{.State.Pid}} 32d7a757bc05
Let say the PID is 3386. When I run
sudo nsenter --target 3386 --mount --uts --ipc --net --pid bash
I get this error
nsenter: failed to execute bash: No such file or directory
But if I change bash
to sh
as below it works
sudo nsenter --target 3386 --mount --uts --ipc --net --pid sh
I'm on Centos 7, docker version 20.10.6 and as you have noticed I'm running my container from bash image. I cannot understand why bash is not working. Can someone please explain this?
Update
Just giving a little bit more background. I'm running my Centos as a Vagrant VM. I used vagrant ssh
to connect to both terminals.
Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.provider "hyperv"
end