Install CloudWatch Logs Agent
Install awscli-cwlogs python module. Amazon provides an interactive installer to do this, but it seems easier, and more repeatable to just install the module.
RUN pip install --trusted-host aws-cloudwatch.s3-website-us-east-1.amazonaws.com --extra-index-url=http://aws-cloudwatch.s3-website-us-east-1.amazonaws.com/ awscli-cwlogs==1.3.3
Configure CloudWatch Logs Agent
Add aws.conf file and awslogs.conf file to /etc/
All applications should be setup to log to syslog, syslog will be configured to write all logs to a single file, the file will be rotated every 25mb.
Add rsyslog.conf file to /etc/.
Add script to remove old log files, remove-old-logs.sh, to /opt/bin/
Configure supervisor to start application, rsyslogd, and Cloudwatch Logs Agent
add start-awslogs.conf, and start-rsyslog.conf to /opt/supervisor/
Configure a supervisor conf file to start the application, then includ the conf files for starting rsyslog and CloudWatch Logs Agent. See web.conf for an example.
Configure Docker to run supervisor
add run_supervisord.sh to /opt/bin/
Set CMD in dockerfile
CMD ["/opt/bin/run_supervisord.sh", "web"]