Install the New Relic Ruby agent in a Docker container. Install the agent within each container you want to monitor.
Prerequisites
Requirement | Details |
|---|---|
New Relic account | You need a New Relic account and your . Have it ready before you begin. |
Ruby version | See Ruby agent requirements and supported frameworks for supported Ruby versions. |
Docker | Docker installed with a Ruby base image. |
Add the gem to your Gemfile
Add the Ruby agent gem to your Gemfile:
gem 'newrelic_rpm'Your Dockerfile should run bundle install as part of the build:
COPY Gemfile Gemfile.lock ./RUN bundle installFramework-specific notes:
- Rails: Rails automatically calls
Bundler.require, sonewrelic_rpmis required during startup with no additional steps. - Roda or Sinatra: You must manually call
require 'newrelic_rpm'in your application. - Other Rack apps: To use automatic browser monitoring, manually include the Rack middlewares provided by the agent.
Configure the agent
Pass your app name and license key as environment variables when running the container — do not hardcode them in your image:
$docker run -e NEW_RELIC_LICENSE_KEY=YOUR_LICENSE_KEY \> -e NEW_RELIC_APP_NAME="Your Application Name" \> YOUR_IMAGE_NAME:latestYou can also set them via ENV in your Dockerfile:
ENV NEW_RELIC_APP_NAME="Your Application Name"For all other configuration options, see Ruby agent configuration.
Verify data is flowing
Run your container and send at least two requests to your application. Wait 2–3 minutes, then open one.newrelic.com > APM and look for your app by name.
Tip
App not appearing? See No data appears (Ruby).
Related articles
- Ruby agent requirements and supported frameworks — Supported Ruby versions.
- Ruby agent configuration — All available configuration settings.
- Install on Heroku — Heroku-specific installation steps.