[Python] How do we install New Relic agent inside a Docker container running Django application?

We’ve a Django based business-critical app running inside a docker container and multiple hosts. Looking for instructions to install NewRelic agent inside the docker container or a way to forward logs out of container to VM host where can install the NR agent. Given containers are very common these days, we’re hoping for a way to aggregate logs from these 4 different containers on 4 different EC2/AWS hosts. Thanks for your guidance.

@breubenstein Welcome to the community :slight_smile: This doc offers guidance on installing the Python agent which is the framework NR uses for Django:


If you run into issue we also have these troubleshooting guides available:

Both of these resources are a good place to start. Let us know if you have further need for assistance. Thanks!

Thanks! The Python agent is running successfully inside our containers.

However there doesn’t seem to be a way forward logs using the Python Agent. For services that aren’t running inside containers we use the New Relic Infrastructure agent to do log forwarding.

So maybe the question should be “how can we install the New Relic Infrastructure agent inside a docker container?”

Forward your logs using the infrastructure agent | New Relic Documentation says “The log forwarding feature is not supported on containerized infrastructure agents”, so we have a concern that it can’t be done.

@breubenstein Thank you for clarifying. I will need to get a support engineer involved to respond to your question.

1 Like

Yes, please. This is blocking newrelic log integration of a business-critical (P0) service. Look forward to hearing from your support engineer. Thank you!

Hi, @breubenstein: Just FYI, the New Relic Infrastructure agent is only one way to forward logs. You may use any log forwarding solution listed here: Enable log management in New Relic | New Relic Documentation. You may even call the Logs API directly from your Python application.

1 Like

@breubenstein just to clarify, that note “log forwarding feature is not supported on containerized infrastructure agents” refers to a specific running mode where the Infrastructure agent is actually packaged into a container. This is typically used for container-as-a-service environments (e.g. Fargate) where you don’t have access to the underlying host.

Since it sounds like you do have access to the underlying host (EC2 instance) I would actually recommend installing the Infrastructure agent there (Guided Install is the easiest way to install it) and just configuring it to forward the relevant Docker container logs. Guided Install will get you started with log forwarding, and there is an example of forwarding Docker container logs in the file section of the Forward your logs using the infrastructure agent document. You may need to modify the path to match your system.

Please let us know how you go with this!

1 Like