---
title: Install the Ruby agent in Docker
source: https://docs.newrelic.com/docs/apm/agents/ruby-agent/installation/ruby-agent-installation-docker
---

Install the New Relic Ruby agent in a Docker container. Install the agent within each container you want to monitor.

## Prerequisites [#prerequisites]

| Requirement           | Details                                                                                                                                                                                                |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **New Relic account** | You need a [New Relic account](https://newrelic.com/signup) and your license key. Have it ready before you begin.                                                                                      |
| **Ruby version**      | See [Ruby agent requirements and supported frameworks](https://docs.newrelic.com/docs/apm/agents/ruby-agent/getting-started/ruby-agent-requirements-supported-frameworks) for supported Ruby versions. |
| **Docker**            | Docker installed with a Ruby base image.                                                                                                                                                               |

## Add the gem to your Gemfile [#install]

Add the Ruby agent gem to your `Gemfile`:

````ruby
gem 'newrelic_rpm'
```

Your `Dockerfile` should run `bundle install` as part of the build:

```dockerfile
COPY Gemfile Gemfile.lock ./
RUN bundle install
```

**Framework-specific notes:**

* **Rails**: Rails automatically calls `Bundler.require`, so `newrelic_rpm` is 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](/docs/agents/ruby-agent/frameworks/rack-middlewares#manual) provided by the agent.

````

## Configure the agent [#configure]

Pass your app name and license key as environment variables when running the container — do not hardcode them in your image:

````bash
docker run -e NEW_RELIC_LICENSE_KEY=YOUR_LICENSE_KEY \
           -e NEW_RELIC_APP_NAME="Your Application Name" \
           YOUR_IMAGE_NAME:latest
```

You can also set them via `ENV` in your `Dockerfile`:

```dockerfile
ENV NEW_RELIC_APP_NAME="Your Application Name"
```

For all other configuration options, see [Ruby agent configuration](/docs/apm/agents/ruby-agent/configuration/ruby-agent-configuration).

````

## Verify data is flowing [#verify]

Run your container and send at least two requests to your application. Wait 2–3 minutes, then open [one.newrelic.com > APM](https://one.newrelic.com/apm) and look for your app by name.

> #### 💡 TIP
>
> App not appearing? See [No data appears (Ruby)](https://docs.newrelic.com/docs/apm/agents/ruby-agent/troubleshooting/no-data-appears-ruby).

## Related articles [#related-docs]

-   [Ruby agent requirements and supported frameworks](https://docs.newrelic.com/docs/apm/agents/ruby-agent/getting-started/ruby-agent-requirements-supported-frameworks) — Supported Ruby versions.
-   [Ruby agent configuration](https://docs.newrelic.com/docs/apm/agents/ruby-agent/configuration/ruby-agent-configuration) — All available configuration settings.
-   [Install on Heroku](https://docs.newrelic.com/docs/apm/agents/ruby-agent/installation/ruby-agent-heroku) — Heroku-specific installation steps.
