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

527
Views
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 answers
Answer question

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 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!