Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

530
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda