After running bash shell remotely in the container with the docker exec command, how can I continue to add other commands to the shell?

now many docker ui can remotely call docker"s rest API to operate the container, and use exec to execute commands inside the running container. Suppose I call the exec API in the following way:
POST hostid:port/containers/ {id} / exec
Parameter:
AttachStderr: true
AttachStdin: true
AttachStdout: true
Cmd: ["bash"]
Tty: true
id: "xxxxxx"
after I have successfully created an exec instance, what should I do to add commands, such as ls, to bash shell?
I hope the bosses passing by will not hesitate to give us advice.

Nov.12,2021

I don't quite understand how the add command in the container has anything to do with the previous rpc interface.

if I want to add a command such as ls, I will find the executable program in HOST, for example, mine is / usr/lib/klibc/ls

then copy the file to the container's rootfs, and the copy method searches for "container and host file sharing"


what does it mean to add a command?
usually you can get the command line by executing docker exec-it container name / container ID bash on the host, or if your basic image is alpine, you can also change bash to sh. Bash itself integrates common and commonly used commands, and generally does not require additional addition. Or if you want to add extra, you should use the package manager.

Menu