docker-machine and amazonec2 driver

I am writing this post in the hopes that someone searching to solve problems I was facing yesterday will find this post and hopefully reduce the amount of hair being pulled from their head.

Setup:

Mac OSX El Capitain: version 10.11.16
docker-machine: version 0.8.2
docker: version 1.12.3
docker-compose: 1.9.0

Dockerfile:

FROM ubuntu:latest
RUN apt-get update -y
RUN apt-get install -y python-pip python-dev build-essential
ENV APP_HOME /web
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
ADD . $APP_HOME
RUN pip install -r requirements.txt

docker-compose.yml

version: ‘2’
services:
 db:
 image: postgres:9.4.1
 ports:
 — “5432:5432”
web:
 build: .
 command: python myapp.py
 ports:
 — “5000:5000”
 links:
 — db
 volumes:
 — .:/code

What I was doing:

I had developed a simple Flask application with a sqlite db within my local docker environment and was attempting to deploy to the AWS container service for the first time.

Lessons Learned:

  1. Specify the ami: The docker-machine command I found on the web in several different places did not specify the ami which meant by default it was using Ubuntu 15.10. docker-machine create -d amazonec2 — amazonec2-access-key ‘<KEY>’ — amazonec2-secret-key <SECRET> — amazonec2-region us-east-1 — amazonec2-subnet-id <SUBNET> — amazonec2-vpc-id <VPC> — amazonec2-zone “b” <MACHINE_NAME> The error I kept receiving was: Error checking and/or regenerating the certs. I finally figured out was that I need to use a different version of Ubuntu. In order to that you need to specify a different ami: docker-machine create -d amazonec2 — amazonec2-access-key ‘<KEY>’ — amazonec2-secret-key <SECRET> — amazonec2-region us-east-1 — amazonec2-subnet-id <SUBNET> — amazonec2-vpc-id <VPC> — amazonec2-zone “b” — amazonec2-ami ami-fce3c696 <MACHINE_NAME>
  2. Re-run eval to point to the correct docker environment variables: If you are running docker-machine locally and you want to then properly run and deploy to amazonec2 you will need to run: eval “$(docker-machine env <MACHINE_NAME>)” in order to ensure all subsequent commands are running against the active docker-machine.
Show your support

Clapping shows how much you appreciated Roger Smith’s story.