[英]How can I automatically put a container on AWS ECS?
I currently use the following procedure to put a docker container to ECS: 我目前使用以下过程将docker容器放入ECS:
aws ecr get-login --profile tutorial
执行aws ecr get-login --profile tutorial
The shell script which creates the container 用于创建容器的shell脚本
# Returned by the command in (1)
sudo docker login -u AWS -p looooong -e none https://foobar.dkr.ecr.us-east-1.amazonaws.com
# Remaining steps
sudo service docker restart
sudo docker build -t ${image} .
sudo docker tag ${image} ${fullname}
sudo docker push ${fullname}
My question: 我的问题:
Currently, I just the sudo docker login ...
line every time manually. 目前,我只是sudo docker login ...
每次手动sudo docker login ...
。 Can I somehow execute aws ecr get-login --profile tutorial
and execute the returned command (with sudo) automatically? 我可以以某种方式执行aws ecr get-login --profile tutorial
并自动执行返回的命令(使用sudo)吗?
Yes, You may use the eval to execute docker login command. 是的,您可以使用eval执行docker login命令。
For Example: 例如:
eval $(aws ecr get-login --no-include-email --region us-west-2)
Sample Shell script in your case would be like: 您的案例中的示例Shell脚本将如下所示:
#!/bin/bash
eval $(aws ecr get-login --no-include-email --region us-west-2)
# Remaining steps
sudo service docker restart
sudo docker build -t ${image} .
sudo docker tag ${image} ${fullname}
sudo docker push ${fullname}
您还可以使用反向引号编写字符串bash命令,以执行它。
`aws ecr get-login --no-include-email --region us-west-2`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.