Log to aws
sudo systemctl edit docker
[Service]
Environment="AWS_ACCESS_KEY_ID=my-aws-access-key"
Environment="AWS_SECRET_ACCESS_KEY=my-secret-access-key"
sudo systemctl daemon-reload
sudo systemctl restart docker
To run a docker image:
docker run --rm --log-driver awslogs \
--log-opt awslogs-region=ap-northeast-1 \
--log-opt awslogs-group=test \
--log-opt awslogs-create-group=true \
busybox /bin/echo hello-world
To run a docker-compose file:
version '3.5'
x-logging:
&default-logging
driver: awslogs
options:
awslogs-region: "ap-south-1"
awslogs-group: "centralizedservice_uat"
awslogs-create-group: "true"
tag: '{{ with split .ImageName ":" }}{{join . "_"}}{{end}}-{{.ID}}'
myservice:
logging: *default-logging