docker run, docker exec and logs docker run, docker exec and logs nginx nginx

docker run, docker exec and logs


When you docker exec you can see you have several process

/ # ps -efPID   USER     TIME   COMMAND    1 root       0:00 nginx: master process nginx -g daemon off;    6 nginx      0:00 nginx: worker process    7 root       0:00 /bin/sh   17 root       0:00 ps -ef/ # 

and in Linux, each process has its own stdin, stdout, stderr (and other file descriptors), in /proc/pid/fd

and so, with your docker exec (pid 7) you display something in

/proc/7/fd/1

If you do ls -ltr /proc/7/fd/1, it displays something like/proc/4608/fd/1 -> /dev/pts/2 which means output is being sent to terminal

while your nginx process (pid 1) displays his output in

/proc/1/fd/1

If you do ls -ltr /proc/1/fd/1, it displays something like /proc/1/fd/1 -> pipe:[184442508] which means output is being sent to docker logging driver