aws-ecs demo | amazon elastic container service demo | aws container demo | aws fargate
aws ecs demo | amazon elastic container service demo | aws container demo | aws fargate
Below topics will cover
- aws ec2 machine creation
- install docker on aws linux machine 2
- create docker image
- create iam user with programmatic access and give permission to ecs, ecr, ec2
- configure user created in above step in linux machine
- create ecr repository and push docker image
- create task definition
- create cluster
- create service
- demo
step to create ec2 machine
click launch instance from the top right side
next select the machine - Amazon Linux 2 AMI
in the choose instance type select - t2.micro
in the configure instance and add storage step - go with default values
give the name of your machine in the add tags section
in the configure security open port 22 and port 80 in the inbound ref screenshot
Click on the next review and launch
create new keypair - give name as per choice, download it on a local machine (key pair require to login to machine )
Download git-bash from https://git-scm.com/downloads
download for windows
go the location where key pair is saved
right-click anywhere on the free space and select git bash from here
install docker on aws linux machine 2
sudo yum update -y
sudo amazon-linux-extras install docker
sudo yum install docker
sudo service docker start
sudo usermod -a -G docker ec2-user
create docker image
create one file - touch Dockerfile
update below content in the Dockerfile create in above step
FROM ubuntu:18.04
# Install dependencies
RUN apt-get update && \
apt-get -y install apache2
# Install apache and write hello world message
RUN echo 'Hello World!' > /var/www/html/index.html
# Configure apache
RUN echo '. /etc/apache2/envvars' > /root/run_apache.sh && \
echo 'mkdir -p /var/run/apache2' >> /root/run_apache.sh && \
echo 'mkdir -p /var/lock/apache2' >> /root/run_apache.sh && \
echo '/usr/sbin/apache2 -D FOREGROUND' >> /root/run_apache.sh && \
chmod 755 /root/run_apache.sh
EXPOSE 80
CMD /root/run_apache.sh
docker build -t hello-world .
search image created in the above step
docker images --filter reference=hello-world
now verify image working properly or not
now verify image working properly or not
docker run -t -id -p 80:80 hello-world
go to aws console, search for IAM
create iam user with programmatic access and give permission to ecs, ecr, ec2
click on create user, give name as per choice
select programmatic access, next in the policy select administrator policy
next, create ( make sure to download the excel file )
configure user created in above step in linux machine
aws configure
https://www.blogger.com/blog/post/edit/4755733674328893075/6044184154345895909?hl=en
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
create ecr repository and push docker image
aws ecr create-repository --repository-name hello-repository --region ap-south-1
next tagging a repository
docker tag hello-world awsaccountnumberhere.dkr.ecr.ap-south-1.amazonaws.com/hello-repository
loginaws ecr get-login-password | docker login --username AWS --password-stdin awsaccountnumberhere.dkr.ecr.ap-south-1.amazonaws.com/hello-repository
to push docker image to ecr
docker push awsaccountnumberhere.dkr.ecr.ap-south-1.amazonaws.com/hello-repository
add container image - format
To delete
aws ecr delete-repository --repository-name hello-repository --region region --force
create task definition
go to aws console - service - search for ecs
click task definition - and create a new task definition
enter task definition name, IAM role ( leave none )
task size ( need to select from below combination only)
leave other options as default and create
create cluster
Click on create a cluster, select networking only
leave the other options as default
create cluster
create service
select the cluster created in the above step
select the service tab
in the launch type select fargate
fill all the other details like task definition, revision, cluster name
give service name as per choice
number of task : 1
next step select the vpc , and subnet
create
verify
Click on the cluster, select service
wait for the service to get into Active state
in the network, section copy the public Ip to verify
Comments
Post a Comment