[英]Deploy Applications on Amazon ECS Using docker compose
我正在嘗試將具有多個服務的 docker 容器部署到 ECS。 我一直在關注這篇看起來很棒的文章: https://aws.amazon.com/blogs/containers/deploy-applications-on-amazon-ecs-using-docker-compose/
我可以讓我的容器在本地運行,並且可以使用 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”
I read here: pull access denied repository does not exist or may require docker login mikemaccana 's answer that after Nov 2020 authentication may be required in your YAML file to allow AWS to pull from hub.docker.io (eg give aws your 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-database
(部署似乎在抱怨,因為它不存在)。 您需要額外的步驟將圖像推送到 GH 或 ECR,然后才能在ecs
上下文中使用docker compose up
來實現它。
您可能還需要更改撰寫版本(“2”非常舊)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.