Docker-node: how to get logs of the node js

Created on 15 Dec 2017  路  4Comments  路  Source: nodejs/docker-node

Hi, I am using docker container of the node :8.9.3 version image, in our production nodejs application is

working fine, please help me to find the directory, where logs are being saved of the nodejs app, or how

can I store logs to analyse.

If any good opensource tool available kindly share the link for the same.

Regards
kartik

question

Most helpful comment

You want run the docker-log to see the stdout output, right?

Assuming the following scenario:

your-daemon-or-script.js

function test() {
  console.log(`Test!`)
}
setInterval(test, 1000)

Running this script as example:

docker run -d --rm --name my-running-script -v "$PWD":/usr/src/app -w /usr/src/app node:8 node your-daemon-or-script.js

You will see the stdout running:

docker logs $(sudo docker ps -aq --filter name=my-running-script)

This command will display:

Test!
Test!
Test!
...

All 4 comments

Node is a pretty big ecosystem. Which node particularly are you looking for?

You want run the docker-log to see the stdout output, right?

Assuming the following scenario:

your-daemon-or-script.js

function test() {
  console.log(`Test!`)
}
setInterval(test, 1000)

Running this script as example:

docker run -d --rm --name my-running-script -v "$PWD":/usr/src/app -w /usr/src/app node:8 node your-daemon-or-script.js

You will see the stdout running:

docker logs $(sudo docker ps -aq --filter name=my-running-script)

This command will display:

Test!
Test!
Test!
...

Closing this as being answered

thanks every one for support...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kmetsalu picture kmetsalu  路  5Comments

dionysiusmarquis picture dionysiusmarquis  路  3Comments

frankbaele picture frankbaele  路  3Comments

kmleow picture kmleow  路  5Comments

polys picture polys  路  3Comments