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

521
Vistas
Writing log files in NodeJS Docker container

I want to write log files to the host file system, so it is persisted, even if the Docker container dies.

Do I need to mount a volume in my Docker yaml?

VOLUME /var/log/myApp

Then do I just reference the mount like this?

var stream = fs.createWriteStream(`/var/log/myApp/myLog.log`);
stream.write('Hello World!');

Then outside of my container, I can go to the /var/log/myApp/ directory and see my logs.

I am trying to find an example of this, but haven't seen anything.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

When you're setting up your container, you just use the -v argument:

-v ./path/to/local/directory:/var/log/myApp

The first path is where the volume is available on the host system (the period at the beginning means it's relative to where you're running the docker command). The path on the right hand side is where it's available in the container.

Once more, in docker-compose:

    volumes:
        - "./path/to/local/directory:/var/log/myApp"

And yes, this will allow the data stored in the volume to be persistent.

over 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