- AWS X-Ray 构建
1.Acquire Binary X-Ray
mkdir xray-daemon && cd xray-daemon
curl https://s3.dualstack.us-east-1.amazonaws.com/aws-xray-assets.us-east-1/xray-daemon/aws-xray-daemon-linux-2.x.zip -o ./aws-xray-daemon-linux-2.x.zip
unzip -o aws-xray-daemon-linux-2.x.zip -d .
2. Dockerfile (基于Ubuntu构建,AWS ECS OS 默认Ubuntu)
FROM ubuntu:12.04
COPY xray /usr/bin/xray-daemon
CMD xray-daemon -f /var/log/xray-daemon.log &
3.Build
docker build -t xray .
- 在ECR创建镜像仓库(名称与镜像名称一致)
ECR仓库创建地址 - Docker Login 授权
After Docker Build local(本地构建Docker Image 后)
- Shell Install AWS Cli
brew install awscli
aws configure #输入账户配置信息,eg: Access Key, Secret, Region ...
切记: 在IAM添加 Administrator Access
# 选择 region_name
aws ecr get-login --no-include-email --region region_name
执行之后会显示 docker login 命令
# password && url 为 aws ecr get-login --no-include-email --region region_name 生成
# 直接运行即可
docker login -u AWS -p password url
修改tag (个人偏好)
# dis 修改后 xray:latest
# src 修改前 docker build -t xray . (根据build命令生成与AWS相关的tag)
#
docker tag dis src
push
# account_id AWS 账户ID (docker login url)
# https://account_id.dkr.ecr.region_name.amazonaws.com
# region_name 指定 AWS region
docker push account_id.dkr.ecr.region_name.amazonaws.com/xray:latest