AMAZON ECS(4)ECS Configuration

AMAZON ECS(4)ECS Configuration

1 Improvement on Build the Docker Image

Configuration my S3 credentials
Create the credentials
> aws iam create-access-key --user-name carl

> mkdir ~/.aws

> vi ~/.aws/credentials

[default]
aws_access_key_id = AKIAIMP55MN4xxxxxxxx
aws_secret_access_key = BIr5Xlu1jvaFyfKT5DIxxxxxxxxx

After changes for this, we can have s3 command to do some work for us, for example
Copy the S3 file to Our Local in Makefile
app-model:
aws s3 cp s3://xxxx-xxxx/classifier_models.tar.gz .


Build the Tarball file
app-build:
sbt universal:packageZipTarball


Support private Docker Registration
IMAGE=sillycat/xxxxx-play
TAG=1.0
NAME=xxxxx-play
REPOSITORY=registry.sillycat.com

tag-local:
docker tag $(IMAGE):$(TAG) $(REPOSITORY)/$(IMAGE):$(TAG)


push-local:
docker push  $(REPOSITORY)/$(IMAGE):$(TAG)


Fix Permission Issue
FATA[0000] Get http:///var/run/docker.sock/v1.18/images/json: dial unix /var/run/docker.sock: permission denied. Are you trying to connect to a TLS-enabled daemon without TLS?

Solution:
> sudo usermod -a -G docker carl

Restart the Server, it will work.

Pass parameter when we run the image
run-stage:
sudo docker run -d -p 8003:8003 -e RUNNING_ENV=stage --name $(NAME) $(IMAGE):$(TAG)


Auto Unzip for these files on Dockerfile
ADD             xxxxxx_models.tar.gz /share/
ADD             target/universal/xxxxx-play-1.0.tgz /share/

2 Steps to Build the ECS

Create a ECS first, Add EC2 Instances there.

EC2 AWS= Search ECS  and choose  Amazon ECS-Optinmized Amazon

Go to EC Configuration —> Advanced —> Add these command there:
echo ECS_CLUSTER=fr-production >> /etc/ecs/ecs.config
mkdir -p /media/ephemeral0/docker
source /etc/sysconfig/docker && echo OPTIONS=\"$OPTIONS -g /media/ephemeral0/docker\" >> /etc/sysconfig/docker
service docker restart

This command will start the EC2 instances and ask it to join the ECS cluster. In the mean time, they will use the share driver to store all the docker images and data.

Check where this directory is amount to
>sudo -h /var/lib/docker/devicemapper/devicemapper/data

Create ECS

Create EC2

Create Task Define

Create LB

Later I will go and read the documents about AWS Gateway.

猜你喜欢

转载自sillycat.iteye.com/blog/2263318
ECS
今日推荐