[英]Single Docker image push into AWS elastic container registry (ECR) from VSTS build/release definition
[英]I am not able to push my docker Image on Elastic container registry
我創建了一個 ecr,我已經通過 aws 進行了身份驗證,我能夠成功進行停靠登錄,但在推送我的圖像時仍然沒有獲得授權我也嘗試了 sudo,但我使用的是 windows
我將錯誤圖像供參考在此處輸入圖像描述
最近做了一個腳本,看看有沒有幫助
import os
def build(account_id, image_name, repository_name, docker_file):
"""
Parameters
----------
account_id: AWS account ID
image_name: Docker image to be built and assigned a name
repository_name: AWS ECR repository name
docker_file: The docker file to use
"""
print("starting docker build...")
os.system(
'docker build --pull --rm -f "'
+ docker_file
+ '" -t '
+ image_name
+ ':latest "."'
)
print("done.")
print("logging in aws ecr...")
os.system(
"aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin "
+ account_id
+ ".dkr.ecr.us-east-1.amazonaws.com"
)
print("done.")
print("tagging...")
os.system(
"docker tag "
+ image_name
+ ":latest "
+ account_id
+ ".dkr.ecr.us-east-1.amazonaws.com/"
+ repository_name
)
print("done.")
print("pushing to ecr...")
os.system(
"docker push "
+ account_id
+ ".dkr.ecr.us-east-1.amazonaws.com/"
+ repository_name
)
print("done.")
if __name__ == "__main__":
docker_file_name = ""
aws_account_id = ""
docker_image_name = ""
ecr_repository_name = ""
build(aws_account_id, docker_image_name, ecr_repository_name, docker_file_name)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.