繁体   English   中英

我无法在弹性容器注册表上推送我的 docker 图像

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM