Lab Title Duration 60 Minutes: Aws Configure
Lab Title Duration 60 Minutes: Aws Configure
Title
Duration 60 minutes
6) In the above commands, you installed docker and git, started docker service and
added permission for the user. Now disconnect the SSH terminal and login again for
the permission changes to take effect. By running docker info, you can verify that the
docker service is running. Next clone a sample php app from git and view the
Dockerfile in it by the following commands.
git clone https://github.com/awslabs/ecs-demo-php-simple-app
cd ecs-demo-php-simple-app
cat Dockerfile
7) Dockerfile contains information about the base image to be used and the operations
such as install packages, configuring the code that are need to be done before
creating a new docker image.
8) Next Im authenticating my Docker client with the following command
aws ecr get-login --region us-west-2
9) Then it returns a Docker command. Just copy that entire text and paste it again in
the terminal. It will return Login succeeded which means your docker client is
successfully registered with your repository
10) Now go to folder containing code and build a docker image with following command.
I create my image with name myrepository same as the repository name.
cd ecs-demo-php-simple-app
docker build -t myrepository .
13) Then in ECS page, click Next, enter a name for task-definition, container name and
click next and again enter service name and click next.
14) In the last screen, enter a name for your cluster and select your keypair if you need
to login into that instance and click Review & launch and again click Launch in the
next page.
15) A new instance with the tasks will be running after a few minutes.
16) It may take some time to start the service and after that check that instances by
navigating the browser to the public IP of the newly created ECS instance. You dont
need to do following steps if the above steps worked fine.
17) Go to ECS page, click Repositories, select the repository you created, click View push
commands. Do the commands 4 & 5 shown on the screen where the syntax is given
on the step 12
18) Now click refresh in ECS page and you can see your docker image is uploaded. Then
click Clusters, click Create Cluster, enter Cluster name, choose t2.micro instance
type, choose your keypair and then click Create
19) Go to Task Definitions on the navigation pane, click Create New Task Definition,
Enter task definition name, click Add Container and enter Container Name.
20) In a new tab, open ECS console, go to repository, copy the repository url and paste it
in the previous tabs image field and also append :latest to that url.
21) Enter memory limit as 128 and in port mappings, enter 80 for both host port and
container port, enter CPU units as 10 and finally click Add at the bottom.
22) Click create and go to Clusters section using left navigation pane.
23) Select your cluster, in service tab click create, choose your task definition and
cluster, enter a service name, Number of tasks as 1 and click Create Service.
24) After few minutes, your service will be changed to running state and after that check
that instances by navigating the browser to the public IP of the newly created ECS
instance.
25) Like this, by adding more images to repository, creating a task definition with
container of the docker image and launching a new service into the cluster, more
service can be ran within a single instance and its health checks can be monitored
and maintained in the service level.