• Log inStart now

Install the Node.js agent for Docker

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.

Instrument your container

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.

  1. Add newrelic to your package.json:

    "newrelic": "latest",

    Install a specific version, or use any of the other options provided by the package.json format. Check the Node.js agent release notes for information about past agent versions.

  2. In the first line of your app's main module, add require('newrelic');.

  3. Add the environment variable NEW_RELIC_NO_CONFIG_FILE=true to your Dockerfile so the agent can run without a configuration file.


This environment variable is no longer required as of v7.2.0 of the Node.js agent. More information on our configuration settings and order of precedence can be found here.

  1. Build your Docker image the way you normally do.

  2. To run your Docker app with the agent enabled, add your license key and app name to your docker run command as environment variables:

          -e NEW_RELIC_APP_NAME="Your Application Name" \

While you wait for your data to come in...

Did this doc help you install?

Other configuration options


Do not include your license key in your Dockerfile or Docker image. For more information, see our documentation on license key security.

In addition to setting your application name or license key, you can set other configuration options by starting your container with the -e option. For example, to enable distributed tracing, use:

        -e NEW_RELIC_APP_NAME="Your Application Name" \

You can also set configuration options in your Dockerfile using ENV directives:

# etc.
Copyright © 2022 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.