Deploy your docker container to AWS

Docker

1. Installation and Configure AWS

1.1 install aws-cli

1
sudo pip3 install awscli

1.2 Create IAM at aws-console

1.3 Configure your IAM token

1
2
3
4
5
6
7
8
9
10
aws configure

AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: ap-southeast-1
Default output format [None]: ENTER

# that will generate file in
~/.aws/config
~/.aws/credentials

2. Create Docker-Machine

The VPC-ID and Subnet-ID should copy from AWS-console.
2.1 Create a docker-machine

1
2
3
4
5
6
7
8
9
docker-machine create \
--driver amazonec2 \
--amazonec2-access-key AKIAIOSFODNN7EXAMPLE \
--amazonec2-secret-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY \
--amazonec2-region ap-southeast-1 \
--amazonec2-subnet-id subnet-16b8e272 \
--amazonec2-vpc-id vpc-b263fdd6 \
--amazonec2-zone a \
ap-southeast-1-docker-machine-1

2.2 Active it

1
2
3
docker-machine ls
docker-machine env ap-southeast-1-docker-machine-1
eval $(docker-machine env ap-southeast-1-docker-machine-1)

2.3 Build and run your project

1
2
3
4
5
6
cd /your/project/root
docker build -t ap-southeast-1/project .
docker run ap-southeast-1/project

docker ps
docker-machine ls

2.4 DONT FORGET TO CONFIGT AWS SECURITY GROUP FOR YOUR APPLICATION

Reference

https://docs.docker.com/machine/drivers/aws/#options