Skip to content

Deploy to AWS using docker machine and docker compose

Julian Espinel edited this page Jan 7, 2017 · 9 revisions

Deploy to AWS using docker-machine and docker-compose

1. Prepare your machine

Please follow this steps:

  1. Install docker in your localhost. Installation link
  2. Install docker-machine in your localhost. Installation link
  3. Install docker-compose in your localhost. Installation link
  4. Create an account in AWS (skip this step if you already have one). AWS
  5. Create the AWS credentials file in your localhost. docker-machine + aws
  6. Log into aws and get your VPC ID
    1. Go to: https://console.aws.amazon.com/vpc/
    2. Click on the VPC link
    3. Copy your VPC ID

2. Deploy to AWS

Please write this commands in your terminal:

  1. docker-machine create -d amazonec2 --amazonec2-vpc-id <your-vpc-id> --amazonec2-ami ami-e13739f6 stockreader
  2. docker-machine env stockreader
  3. eval $(docker-machine env stockreader)
    (From now on all docker, docker-machine and docker-compose commands will point to the AWS EC2 instance)
  4. git clone https://github.com/julianespinel/stockreader.git (clone the project in your localhost)
  5. cd stockreader
  6. docker-compose build
  7. docker-compose up -d

3. Check Stockreader is up and running

Please follow this steps:

  1. Go to your AWS EC2
  2. Click on the "running instances" link
  3. Copy the public IP of the stockreader instance
  4. Check the security group applied to the instance allows inbound TCP traffic to the port 5000
  5. On your browser go to:
    http://<stockreader-instance-public-ip>:5000/stockreader/admin/ping

If you get the following JSON, congratulations! You just deployed Stockreader to AWS using docker-machine and docker compose:

{
    "message": "pong"
}