Skip to content
Charlie Martin edited this page Feb 11, 2017 · 18 revisions

To Do

  • (cloud formation template) Set ec2-user as the user for starting the docker containers. This eliminates the sudo -i command (which is easy to forget)
  • (cloud formation template) Add /usr/local/bin to the path.

Introduction

The CHORDS Docker image can easily be run on AWS. Instructions follow for manually starting a CHORDS server on EC2, as well as an automated procedure using CloudFormation.

Manual Method

Use EC2 to create a bare-bones Linux, using their standard suggested Linux AMI.

ssh into the image, then:

sudo -i
yum update -y
yum install -y docker
service start docker
curl -L https://github.com/docker/compose/releases/download/1.8.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod a+x /usr/local/bin/docker-compose
curl -L https://github.com/NCAR/chords_portal/raw/development/docker-compose.yml > docker-compose.yml
/usr/local/bin/docker-compose pull
/usr/local/bin/docker-compose -p chords up -d
docker ps -a
docker volume ls

CloudFormation

We have a CloudFormation template now, in bin/docker.template (and also on Amazon S3). It is much simpler than the original CloudFormationtemplate. Be sure to specify an ssh key, and to set rollback to false. The create timeout is a more comfortable 10m.

With this stack running, you can update CHORDS on the AWS instance by:

ssh -i <key> <EC2 instance ip>
sudo -i
/usr/local/bin/docker-compose pull 
/usr/local/bin/docker-compose -p chords down
/usr/local/bin/docker-compose -p chords up -d

We will come up with some hooks for backing up the database from the mysql volume.

Debugging CloudFormation

  • Select the standard AWS ssh key. When creating the stack, specify a reasonably short creation timeout on the configuration screen.
  • Turn off "rollback on failure". If creation fails. the instance will be left running. You will be able to ssh and look at logs, try running the commands by hand, etc.
  • It's very helpful to look at /var/log/cfn-init-cmd.log. There you can examine the creation commands (and output) that were derived from the template.

Issues

I found that io wait went through the roof and the site became unresponsive, when running on a t2.micro. I tried a t2.small, and the problem disappeared. It seems like mysql was running out of ram for it's database access. I found a nice writeup on this issue.

Links

  • A very detailed tutorial about running docker on AWS. It touches on several AWS services, including EC2, ECS and ELB.
Clone this wiki locally