首页 > 解决方案 > 使用 ecs-cli 在 aws 上部署 docker compose 会出现错误

问题描述

使用 ecs-cli 将 docker compose 文件部署到 aws 时出现内部错误。在我的控制台中,我了解到该服务已启动并在 aws gui 中运行,但是当我尝试打开链接时出现内部错误。亚马逊视图 链接不起作用

Dockerfile.txt

FROM clojure:openjdk-8-lein

RUN apt update && apt install -y git make python3 && apt clean
WORKDIR /opt
RUN mkdir my-project && cd my-project && git clone https://github.com/ThoughtWorksInc/infra-problem.git && cd infra-problem && make libs && make clean all

码头工人-compose.yml

version: "3"
services:
  quotes:
    image: selmensh/newsfeeds
    build:
        context: .
        dockerfile: ./Dockerfile.txt
    container_name: quotes
    command: java -jar ./my-project/infra-problem//build/quotes.jar
    environment:
      - APP_PORT=9200
    ports:
      - 9200:9200
  newsfeed:
    image: selmensh/newsfeeds
    build: 
        context: .
        dockerfile: ./Dockerfile.txt
    container_name: newsfeed
    command: java -jar ./my-project/infra-problem/build/newsfeed.jar
    environment:
      - APP_PORT=5000
    ports:
      - 5000:5000
  assets:
    image: selmensh/newsfeeds
    build: 
        context: .
        dockerfile: ./Dockerfile.txt
    container_name: assets
    command: python3 ./my-project/infra-problem/front-end/public/serve.py
    ports:
      - 8000:8080
  front-end:
    image: selmensh/newsfeeds
    build: 
        context: .
        dockerfile: ./Dockerfile.txt
    command: java -jar ./my-project/infra-problem/build/front-end.jar
    environment:
      - APP_PORT=8081
      - STATIC_URL=http://assets:8000
      - QUOTE_SERVICE_URL=http://quotes:9200
      - NEWSFEED_SERVICE_URL=http://newsfeed:5000
      - NEWSFEED_SERVICE_TOKEN=T1&eWbYXNWG1w1^YGKDPxAWJ@^et^&kX
    depends_on:
      - quotes
      - newsfeed
    ports:
      - 80:8081

我还注意到 ecs 不支持构建,所以我制作了一个图像并推送到 docker hub。但是我发现这可能存在一些安全问题,因为我在 docker 文件中克隆了代码。我这样做的原因是因为代码有一个名为实用程序的文件夹,该文件夹很常见,并且是所有其他服务所必需的。有更好的方法吗?

标签: amazon-web-servicesdocker-composeamazon-ecs

解决方案


如果您可以展示更多细节,那就太好了,这似乎是您的应用程序中的一个问题,现在我可以向您指出的是terraform工具,通过它您可以更好地管理您的基础设施(幂等性)。


推荐阅读