一開始主要照著 AWS ECS 裡的基本範例進行
http://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html
然後用 AWS ECS 來輕鬆部署群集
建立 ec2 時要選擇 Amazon ECS-optimized AMI (針對docker優化過的機器)
然後設置
#!/bin/bash
yum update -y ecs-init
echo ECS_CLUSTER=your_cluster_name
>> /etc/ecs/ecs.config
這樣 這台 EC2 才能和你的 ECS 關聯
官方 image 集中地
https://hub.docker.com/
Amazon Linux 的 Docker imagehttps://lambda-linux.io/
然後發現了這本電子書
https://www.gitbook.com/book/philipzheng/docker_practice/details
Docker官網
https://docs.docker.com/
#用一個 image 開新 container
$ docker run "image_name"
#更新一個 image (更新)
$ docker commit -m "message" -p "container_id" "tag"
#建立容器指定本機port 7000 指到 容器port 80並啟動apache
docker run -idt -p 7000:80 [RUI]/amazonlinux:latest /sbin/init
#複製資料(cp完後要對容器restart)
docker cp /Users/paul/Downloads/sampleapp/index.html [CID]:/var/www/html
#用資料卷
docker run -idt -p 5000:80 -P --name web -v /Users/paul/Documents/amazon-linux-docker-images/html:/var/www/html amazonlinux:latest /sbin/init
commit時資料卷資料不會更著複製
#進去
#用資料卷和本機共用aws credentials
docker run -idt -p 5000:80 -P --name web -v /Users/paul/Documents/amazon-linux-docker-images/html:/var/www/html amazonlinux:latest /sbin/init
commit時資料卷資料不會更著複製
#進去
docker exec -ti cid bash
#用資料卷和本機共用aws credentials
cat ~/.aws/credentials
docker run -idt -p 5000:80 -P --name aws -v /Users/paul/.aws/:/root/.aws/ amazonlinux:latest /sbin/init
docker run -idt -p 7000:80 -v /Users/paul/.aws/:/root/.aws/ -v /Users/paul/Documents/amazon-linux-docker-images/html:/var/www/html [RUI]/udn/amazonlinux:latest /sbin/init
docker run -idt -p 7000:80 -v /Users/paul/.aws/:/root/.aws/ -v /Users/paul/Documents/amazon-linux-docker-images/html:/var/www/html [RUI]/udn/amazonlinux:latest /sbin/init
docker run -idt -p 6000:80 -v /Users/paul/.aws/:/root/.aws/ -v /Users/paul/Documents/111222:/var/www/html [CID] /sbin/init
清理log
https://groups.google.com/forum/#!topic/docker-dev/mIZ7UDp7go0
ecs收集log上傳到CloudWatch
http://docs.aws.amazon.com/zh_cn/AmazonECS/latest/developerguide/using_cloudwatch_logs.html
#aws
#DevOps
清理log
https://groups.google.com/forum/#!topic/docker-dev/mIZ7UDp7go0
To find out where the log file is : docker inspect --format='{{.LogPath}}' $INSTANCE_ID
For cleaning the logs : sudo sh -c ": > $(docker inspect --format='{{.LogPath}}' $INSTANCE_ID)"
ecs收集log上傳到CloudWatch
http://docs.aws.amazon.com/zh_cn/AmazonECS/latest/developerguide/using_cloudwatch_logs.html
#aws
#DevOps
沒有留言:
張貼留言