This container is intended to upload logfiles to Amazon CloudWatch Logs service. If you don't set any environment variables, container will start with the following config:
[/mnt/logs/access.log]
datetime_format = %d/%b/%Y:%H:%M:%S %z
file = /mnt/logs/access.log
buffer_duration = 5000
log_stream_name = {instance_id}
initial_position = start_of_file
log_group_name = nginx-server
AWS_LOGFILEdefault is "/mnt/logs/access.log"AWS_LOGFORMATdefault is "%d/%b/%Y:%H:%M:%S %z"AWS_DURATIONdefault is "5000"AWS_GROUPNAMEdefault is "nginx-server"AWS_STREAM_NAMEdefault is the instance_idAWS_REGIONdefault is us-east-1 (region where logs are published)AWS_INITIAL_POSITIONdefault is start-of-file (other option is end-of-file)
If you have not defined a role for this instance, then you will need to pass the AWS keys
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY
# Run container with Nginx
docker run -d --name nginx -v /mnt/logs:/var/log/nginx -p 80:80 sergeyzh/centos6-nginx
# Run container with AWS CloudWatch logs uploader
docker run -d --name awslogs -e AWS_LOGFILE=/mnt/logs/access.log -e AWS_DURATION=10000 -v /mnt/logs:/mnt/logs drosenstark/awslogs
Now you can see access logs of your Nginx at AWS Console.
NOTE: Of course you should run it on the Amazon EC2 and you should set IAM role for you instance according manual.
If you do not then run as follows
docker run -d --name awslogs -e AWS_LOGFILE=/var/log/applogs.log
-e AWS_STREAM_NAME="web-2" -e AWS_DURATION=5000 -e AWS_GROUPNAME=/dev/web
-e AWS_REGION=us-west-2 -e AWS_INITIAL_POSITION="end-of-file"
-e AWS_ACCESS_KEY_ID= -e AWS_SECRET_ACCESS_KEY=
-e AWS_LOGFORMAT="%Y-%m-%d %H:%M:%S" -v /var/lib/docker/log/myapp/:/var/log
drosenstark/awslogs:latest
- Ryuta Otaki otaki.ryuta@classmethod.jp
- Sergey Zhukov sergey@jetbrains.com
- David Rosenstark drosenstark@gmail.com