0

I have this:

ENTRYPOINT ["node", ".", "|", "tee", ">(echo 'bar')"]

but it doesn't seem to work, perhaps because tee is not installed in my container. Is this the right way to do this though? I want to run the container on ECS, send the stdout/stderr from the node process to the containers stdout/stderr but also capture it.

For example I tried doing this instead:

ENTRYPOINT ["node", ".", "|", "cat > /dev/null"]

and that didn't work as expected. However, this did seem to work:

ENTRYPOINT node . | cat > /dev/null

anybody know why?

1 Answers1

0

I want to run the container on ECS, send the stdout/stderr from the node process to the containers stdout/stderr

You do need to cat or tee etc if you the node is main process of the container it will write logs to stdout/stderr of the container. if you writing logs to file, then better to logs these logs to console as writing logs to file in container is good for nothing.

Also, you will able to catch these log in your cloud watch if configured.

Just add this and it will enough to handle the log case.

FROM node:alpine
WORKDIR /app
CMD ["node", "app/server.js"]

So this is how the logs flow will look like.

enter image description here

Or If you want to push to ELK then the flow will be

enter image description here

Adiii
  • 54,482
  • 7
  • 145
  • 148
  • sure, how do I capture the stdout from the container then using ECS etc? –  Sep 18 '19 at 21:59
  • 1
    both sdtout and stderr will be write to cotnainer logs and you can do any thing with container logs on ECS. push to ELK, cloud watch etc – Adiii Sep 18 '19 at 22:00
  • thanks can you link to info on how to send the logs from the containers to ElasticSearch? –  Sep 18 '19 at 22:01
  • once your log configured to send to cloud watch then you can stream to ELK. – Adiii Sep 18 '19 at 22:05
  • you can check my this answer. https://stackoverflow.com/questions/57089289/how-to-choose-different-lambda-function-while-start-streaming-to-amazon-elastics/57121871?noredirect=1#comment102403217_57121871 – Adiii Sep 18 '19 at 22:05
  • https://docs.aws.amazon.com/AmazonECS/latest/userguide/using_awslogs.html link that can help in with log driver – Adiii Sep 18 '19 at 22:18
  • 1
    thanks, it looks like ECS automatically stores logs for containers in some cloud repo, without having to explicitly connect them to cloudwatch - maybe you can answer this question? https://stackoverflow.com/questions/58001403/how-to-get-all-logs-from-an-ecs-cluster –  Sep 18 '19 at 22:19