The blog about containerisation, virtual machines and useful shell snippets and findings

Stream docker container logs to the AWS CloudWatch

  1. Configure a role for EC2 instance with permissions to write to the CloudWatch.
  2. Assign that role to EC2 instance with docker.
  3. Open CloudWatch and create docker-logs logging group.
  4. Login into EC2 node and create file
{
  "log-driver": "awslogs",
  "log-opts": {
   "awslogs-group": "docker-logs"
  }
}
  1. Restart docker with
systemctl restart docker

That’s it.

  1. Go to the CloudWatch group and check logs, everything should be there :)