Stream docker container logs to the AWS CloudWatch
- Configure a role for EC2 instance with permissions to write to the CloudWatch.
- Assign that role to EC2 instance with docker.
- Open CloudWatch and create docker-logs logging group.
- Login into EC2 node and create file
{
"log-driver": "awslogs",
"log-opts": {
"awslogs-group": "docker-logs"
}
}
- Restart docker with
systemctl restart docker
That’s it.
- Go to the CloudWatch group and check logs, everything should be there :)