I am learning docker basics right now and stuck on this one: I created a docker container:
docker container run -d -t --name t_d_container linux
fd91f24a79e007d3676b2ab2344b34765829b918672abf4c7995836ad68d0f35
docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fd91f24a79e0 oraclelinux "/bin/bash" 6 seconds ago Up 5 seconds t_d_container
docker container attach t_d_container
[root@fd91f24a79e0 /]# exit
But when I exit from the container it keeps running and waiting for me to give an input. So i have to do CTRL+C everytime.
Then, I tried
docker container exec -it t_d_container /bin/bash
And as expected, there are 2 processes running for bash now:
[root@fd91f24a79e0 /]# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 06:49 pts/0 00:00:00 /bin/bash
root 27 0 0 07:08 pts/1 00:00:00 /bin/bash
Is there any other way to exit from a container running in the background?
I dig in further. After I attach to the container, I am unable to execute any commands on the attached container.
docker container attach ac9d50c03304
[root@ds001 /]# hostname
It just sits there waiting for me to press CTRL+C. DockerVersion:19.03.9