Amazon web services 使用docker compose在Amazon ECS上部署应用程序

Amazon web services 使用docker compose在Amazon ECS上部署应用程序,amazon-web-services,docker,docker-compose,amazon-ecs,Amazon Web Services,Docker,Docker Compose,Amazon Ecs,我正在尝试将具有多个服务的docker容器部署到ECS。我一直在关注这篇看起来很棒的文章: 我可以让我的容器在本地运行,我可以使用AWS CLI连接到ECS上下文;但是在文章的基本示例中,当我运行 docker compose up 为了将映像部署到ECS,我得到了一个错误: pull access denied, repository does not exist or may require authorization: server message: insufficient_scop

我正在尝试将具有多个服务的docker容器部署到ECS。我一直在关注这篇看起来很棒的文章:

我可以让我的容器在本地运行,我可以使用AWS CLI连接到ECS上下文;但是在文章的基本示例中,当我运行

docker compose up 
为了将映像部署到ECS,我得到了一个错误:

pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
我似乎不明白这件事的来龙去脉。我的docker已使用登录到ECS

aws ecr get-login-password --region region | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com
我的aws CLI上的默认IAM用户具有AmazonECS_FullAccess以及“ecs:ListAccountSettings”和“cloudformation:ListStackResources”

我在这里读到:Mikemacana的回答是,在2020年11月之后,您的YAML文件中可能需要身份验证,以允许AWS从hub.docker.io提取(例如,给AWS您的docker hub用户名和密码),但我无法在我的YAML文件中使用“auth”语法。这是我在本地运行tomcat和mariadb的YAML文件:

version: "2"

services:

  database:
    build:
      context: ./tba-database
    image: tba-database
    # set default mysql root password, change as needed
    environment:
      MYSQL_ROOT_PASSWORD: password
    # Expose port 3306 to host. Not for the application but
    # handy to inspect the database from the host machine.
    ports:
      - "3306:3306" 
    restart: always

  webserver:
    build: 
      context: ./tba-webserver
    image: tba-webserver
    # mount point for application in tomcat
    volumes:
      - ./target/testPROJ:/usr/local/tomcat/webapps/ROOT
    links:
      - database:tba-database
    # open ports for tomcat and remote debugging
    ports:
      - "8080:8080" 
      - "8000:8000"
    restart: always
这里是博客的作者(谢谢你的好意评论!)。我对构建方面没有太多了解,但我怀疑这里发生的事情是,当您运行
docker compose up
时,我们忽略了
build
阶段,只利用
image
字段。接下来发生的事情是,部署在ECS/Fargate上的容器试图拉取映像
tba数据库
(这正是部署人员抱怨的地方,因为它不存在)。在使用
ecs
上下文中的
docker compose up
将图像推送到GH或ECR之前,您需要额外的步骤

您可能还需要更改撰写版本(“2”非常旧)