You can use our Node.js agent to instrument Node.js applications deployed in Docker containers. This document explains how to build, configure, and deploy your Dockerized Node.js application that has been instrumented with New Relic.
To use Node.js or any other agent, as well as the rest of our observability platform, join the New Relic family! Sign up to create your free account in only a few seconds. Then ingest up to 100GB of data for free each month. Forever.
With just a few additions your existing Dockerfile can be used with our Node.js agent. You'll configure the agent by running your new Docker image with environment variables set.
In the first line of your app's main module, add
Add this line to your Dockerfile so the agent can run without a configuration file:ENV NEW_RELIC_NO_CONFIG_FILE=true
Build your Docker image the way you normally do.
docker run -e NEW_RELIC_LICENSE_KEY=YOUR_LICENSE_KEY \ -e NEW_RELIC_APP_NAME="Your Application Name" \ your_image_name:latest
Do not include your license key in your Dockerfile or Docker image. For more information, see our documentation on license key security.
$ docker run -e NEW_RELIC_LICENSE_KEY=YOUR_LICENSE_KEY \ -e NEW_RELIC_APP_NAME="Your Application Name" \ -e NEW_RELIC_DISTRIBUTED_TRACING_ENABLED=true \ your_image_name:latest
You can also set configuration options in your Dockerfile using
ENV NEW_RELIC_DISTRIBUTED_TRACING_ENABLED=true \NEW_RELIC_LOG=stdout# etc.
If you need more help, check out these support and learning resources:
- Browse the Explorers Hub to get help from the community and join in discussions.
- Find answers on our sites and learn how to use our support portal.
- Run New Relic Diagnostics, our troubleshooting tool for Linux, Windows, and macOS.
- Review New Relic's data security and licenses documentation.