Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

532
Views
docker run, docker exec and logs

If I do :

docker run --name nginx -d nginx:alpine /bin/sh -c 'echo "Hello stdout" > /dev/stdout'

I can see "Hello stdout" when I do :

docker logs nginx

But when the container is running (docker run --name nginx -d nginx:alpine) and I do :

docker exec nginx /bin/sh -c 'echo "Hello stdout" > /dev/stdout'

or when I attach the container with :

docker exec -it nginx /bin/sh

and then :

echo "Hello stdout" > /dev/stdout

I can't see anything in docker logs. And since my Nginx access logs are redirected to /dev/stdout, I can't see them as well.

What is happening here with this stdout ?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

When you docker exec you can see you have several process

/ # ps -ef
PID   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

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!