Created
March 21, 2018 10:02
-
-
Save krishnamurthydasari/7314d3400280a806cf22f30103ec44c9 to your computer and use it in GitHub Desktop.
Amazon ECS Notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Amazon Elastic Container Servie: Native Doctor Support on AWS | |
User Cases: | |
Configuration and deployment | |
Microservices | |
Breaking application into smaller chunks of code | |
Batch Processing | |
Building block service | |
Manage cluster state | |
Manage containers | |
Schedule containers | |
Performance at scale | |
Key Components: | |
Tasks | |
Containers | |
Clusters | |
Container Instances | |
Container Instances: | |
An EC2 instances with Docker daemon running and Amazon ECS Agent | |
Agent tracks the state of container instances and make the service aware of the state of container instances | |
Clusters: | |
Group of container instances, They are Regional - spans across multiple AZs, They provide resource pool of CPU, Memory and Network etc. | |
You can start empty cluster and dynamically scale it. | |
Task Definition: | |
Task Definition : Defines which Docker image to use for containers and how many containers to use in the task, and the resource allocation for each container | |
Service : A service allows you to run and maintain a specified number (the "desired count") of simultaneous instances of a task definition in an ECS cluster | |
Docker Notes: | |
============= | |
Dockerfile: | |
----------- | |
FROM amazonlinux | |
RUN yum install -y nginx | |
RUN echo "Hello Krishn!" > /usr/share/nginx/html/index.html | |
EXPOSE 80 | |
CMD ["nginx"] | |
--------------- | |
Create build: | |
docker build -t testimage:0.0.1 . | |
docker images | |
docker rmi 332af0eb4121 | |
docker images -a | |
Running build: | |
docker run --name testcontainer -p 80:80 <imagename>:<tag> | |
docker ps -a | |
docker ps | |
docker rm $(docker ps -aq) | |
docker run --name samplecontainer -p 80:80 -d 11c206b5e505 | |
[root@ip-10-0-0-211 ~]# docker ps | |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | |
0cdaf477b9bd 11c206b5e505 "nginx -g 'daemon ..." 3 minutes ago Up 3 minutes 0.0.0.0:80->80/tcp samplecontainer | |
[root@ip-10-0-0-211 ~]# docker exec -it 0cdaf477b9bd /bin/bash | |
bash-4.2# ls | |
bin boot dev etc home lib lib64 local media mnt opt proc root sbin selinux srv sys tmp usr var | |
bash-4.2# pwd | |
/ | |
bash-4.2# cd /usr/share/nginx/html/ | |
bash-4.2# ll | |
bash: ll: command not found | |
bash-4.2# ls | |
404.html 50x.html index.html nginx-logo.png poweredby.png | |
bash-4.2# more index.html | |
Hello Krishn! | |
bash-4.2# | |
bash-4.2# ps -ef | |
UID PID PPID C STIME TTY TIME CMD | |
root 1 0 0 16:28 ? 00:00:00 nginx: master process nginx -g daemon off; | |
nginx 5 1 0 16:28 ? 00:00:00 nginx: worker process | |
nginx 6 1 0 16:28 ? 00:00:00 nginx: worker process | |
root 7 0 0 16:33 pts/0 00:00:00 /bin/bash | |
root 16 7 0 16:34 pts/0 00:00:00 ps -ef | |
bash-4.2# | |
bash-4.2# exit | |
exit | |
[root@ip-10-0-0-211 ~]# df -h | |
Filesystem Size Used Avail Use% Mounted on | |
devtmpfs 3.9G 56K 3.9G 1% /dev | |
tmpfs 3.9G 0 3.9G 0% /dev/shm | |
/dev/xvda1 20G 1.4G 19G 8% / | |
overlay 20G 1.4G 19G 8% /var/lib/docker/overlay2/7c25dab27131c1b780699b66c3c524468a622c3a6edad64c832a60f8d2151a1c/merged | |
shm 64M 0 64M 0% /var/lib/docker/containers/0cdaf477b9bdc67fe3e1d5d14f12f437f70353e4dcc6dde6b82b237d41f71d45/shm | |
[root@ip-10-0-0-211 ~]# docker ps | |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | |
0cdaf477b9bd 11c206b5e505 "nginx -g 'daemon ..." 6 minutes ago Up 6 minutes 0.0.0.0:80->80/tcp samplecontainer | |
[root@ip-10-0-0-211 ~]# docker stop 0cdaf477b9bd | |
0cdaf477b9bd | |
[root@ip-10-0-0-211 ~]# docker rm 0cdaf477b9bd --> to terminate container^C | |
[root@ip-10-0-0-211 ~]# docker start 0cdaf477b9bd | |
0cdaf477b9bd | |
[root@ip-10-0-0-211 ~]# docker ps | |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | |
0cdaf477b9bd 11c206b5e505 "nginx -g 'daemon ..." 10 minutes ago Up 3 seconds 0.0.0.0:80->80/tcp samplecontainer | |
[root@ip-10-0-0-211 ~]# docker stop 0cdaf477b9bd | |
0cdaf477b9bd | |
???? how to mount volume in host from existing container | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment