I have a dockerized application that I am going to host on AWS ECS, I need to monitor it with new relic, one way is to basically install the new relic agent on the EC2 that was created by the ECS.
But what I want is that is it possible that I integrate the new relic image or something on the dockerfile so I dont need to ssh in to the EC2 instance to get the logs and mterics?
It sounds like you may be looking for the New Relic APM agents (which will gather metrics, error events, etc from your containerized applications), these can be packaged into your container images like you've mentioned. The steps are slightly different depending on your app language, examples:
(Instructions for the other language agents are also listed on the New Relic Docs site.)
For monitoring of the ECS infrastructure layer itself, you may want to check out the ECS integration (note that there are different install instructions for EC2 or Fargate launch types): https://docs.newrelic.com/docs/integrations/elastic-container-service-integration/get-started/introduction-amazon-ecs-integration/