Docker组合ECS错误:资源处理程序返回消息:“模型验证失败(#/卷:数组项不是唯一的)" [英] Docker compose up ECS error: Resource handler returned message: "Model validation failed (#/Volumes: array items are not unique)"

查看:122
本文介绍了Docker组合ECS错误:资源处理程序返回消息:“模型验证失败(#/卷:数组项不是唯一的)"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试将Postgres +后端+ Prisma映像部署到Amazon ECS,但是遇到了此错误:

I have been trying to deploy my Postgres + Backend + Prisma images to Amazon ECS but have been running into this error:

资源处理程序返回消息:模型验证失败(#/卷:数组项不是唯一的)"

Resource handler returned message: "Model validation failed (#/Volumes: array items are not unique)"

我已经坚持了几天,任何帮助将不胜感激.我使用Amazon ECS上下文运行 docker compose up 来解决此错误.

I have been stuck on this for a couple of days and any help would be appreciated. I run docker compose up using my Amazon ECS context to get to this error.

version: '3.4'
    services:
      db:
        container_name: db
        ports:
          - 5432:5432
        image: postgres:latest
        environment:
          - POSTGRES_USER=[user]
          - POSTGRES_PASSWORD=[password]
        volumes:
          - my-vol:/var/lib/postgresql/data/2
      backend:
        depends_on:
          - db
        container_name: backend
        ports:
          - 4000:4000
        image: [backend image name]
      prisma:
        depends_on:
          - db
        container_name: prisma
        ports:
          - 5555:5555
        image: [prisma image name]
        environment:
          NODE_ENV: production
    volumes:
      my-vol:

推荐答案

此处是AWS容器服务团队的成员.我从未见过该错误,但是有一些事情在上面的代码中看起来不正确,这使我无法对其进行测试.

AWS container service team member here. I have never seen that error but there are a few things that don't seem right in the code above and that prevent me to be able to test it.

  • 服务应使用版本缩进
  • 如果我尝试使用该卷映射启动(在AWS中)Postgres,则会吐出"initdb:error:directory"/var/lib/postgresql/data.存在但不为空".错误.即使我没有在Docker主机上进行进一步的调查,即使在Docker主机上本地启动(使用 docker-compose up ),Postgres也会失败.您有/2 的原因吗?那应该行吗?
  • 您可以通过指定 host:container 端口通过负载平衡器公开所有服务.我假设您只希望暴露 prisma 容器?还是我误解了你在做什么?
  • services should be indented with version
  • if I try to bring up (in AWS) Postgres with that volume mapping it spits an "initdb: error: directory "/var/lib/postgresql/data" exists but is not empty" error. Postgres fails even if brought up locally on a docker host (with docker-compose up) albeit I did not investigate further there. Is there a reason why you have the /2? Is that supposed to work?
  • You expose all services via the load balancer by specifying the host:container ports. I assume you only want the prisma container to be exposed? Or am I misinterpreting what you are doing?

这是您撰写的稍作修改的版本,对于我来说似乎还不错:

This is a slightly modified version of your compose that seems to be working just fine for me:

version: '3.4'
services:
  db:
    container_name: db
    image: postgres:latest
    environment:
      - POSTGRES_USER=me
      - POSTGRES_PASSWORD=mypassword
    volumes:
      - my-vol:/var/lib/postgresql/data
  backend:
    depends_on:
      - db
    container_name: backend
    image: nginx
  prisma:
    depends_on:
      - db
    container_name: prisma
    ports:
      - 80:80
    image: nginx
    environment:
      NODE_ENV: production  
volumes:
  my-vol:

请注意,我刚刚用伪造的nginx图像更改了prisma和后端容器图像,只是为了提高堆栈的质量(我还不得不将端口更改为 80:80 ).

Note I have just changed the prisma and backend container images with fake nginx images just for the purpose of bringing the stack up (I also had to change the port to 80:80).

这篇关于Docker组合ECS错误:资源处理程序返回消息:“模型验证失败(#/卷:数组项不是唯一的)"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆