I run a Cisco XRd docker container on my Linux Ubuntu host. I run the image using docker run -it -d command. The image's entrypoint is /usr/sbin/init, indeed:
root@eve-ng-6:/opt/unetlab/html# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2ed1b2e66197 ios-xr/xrd-control-plane:latest "/usr/sbin/init" 20 hours ago Up 3 hours 75bc86e8-108a-4300-863a-2141b5718b55-0-2
root@eve-ng-6:/opt/unetlab/html#
Then by using docker attach, I can attach to the running docker container.
Af far as I understand, see Comparing Docker Exec and Docker Attach, docker attach does not start any new process within the container but simply attaches the current terminal to the stdin/stdout/stderr of the container's primary process (i.e. to the process running the image's entrypoint). In my case it is /usr/sbin/init from Cisco XRd.
My question: is the /usr/sbin/init process that is actually "talking" with the user (me) by reading and writing to the attached pseudo-terminal ?
P.s. note that a pseudo-terminal is allocated by virtue of the -d option in docker run command.
docker psoutput'sCOMMANDfield is the actively running process that thedocker attachcommand connects you to. As the answers and comments in this SO question say, that's not necessarily the case. The entrypoint command may be only short-lived, replaced by another program/command it launches. Ot it can be long-lived. It depends on the software in the container image.docker psoutput'sCOMMANDfield is the name of the command when the container was started. Later, upon docker attaching to it, the actual program/executabledocker attachattaches to may be different from that.