As a summary: No commands exist in Busybox "sh" in a Portainer Docker container.
Nuances, as always:
There is a Portainer tool image I'd like to have shell access in. Why I need shell access there? It's because I'd like to discover the ability to connect more than one docker context (other than default) via additional docker socket file mapping.
Portainer developers take some steps (they say for security reasons) to disable the ablity to get an interactive console inside the running container - there are no bin/bash, bin/sh etc.
I've downloaded Busybox from https://busybox.net/downloads/binaries/1.35.0-x86_64-linux-musl/busybox
and created my own debug container based on th original Portainer one:
Dockerfile:
FROM portainer/portainer-ce:2.9.3
LABEL destiny="Portainer debug"
ADD busybox busybox
ENTRYPOINT [""]
CMD [""]
Executed image build command:
docker build -f Dockerfile -t portainer_debug:latest .
... and started a container with it:
docker run --name ppp -it portainer_debug /busybox sh
I entered into a shell inside of the running container.
Unfortunately, I found that there are no commands available.
For example, ls command returns:
/ # ls
sh: ls: not found
/ #
It also means that Busybox commands (sh above) work as a parameter at container start. I checked it with "ls" as a paramater:
$ docker run --name ppp -it portainer_debug /busybox ls
busybox docker-compose kubectl sys
data etc portainer tmp
dev helm proc
docker kompose public
$
Note: "exit" command works inside "sh".
The same excercise with alpine image works as expected:
/ # ls
bin busybox dev etc home lib media mnt opt proc root run sbin srv sys tmp usr var
/ #
I'd be glad and very thankful if somebody could suggest the next steps to understand why busybox "forgets" all commands.