简体   繁体   English

在ElasticBeanstalk上部署多容器应用程序时出现CannotPullContainerError

[英]CannotPullContainerError on Deploying Multi-container App on ElasticBeanstalk

I have a multi-container app which I want to deploy on ElasticBeanstalk. 我有一个要在ElasticBeanstalk上部署的多容器应用程序。 Below are my files. 以下是我的文件。

Dockerfile Dockerfile

FROM python:2.7

WORKDIR /app

ADD . /app

RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get install -y \
    apt-utils \
    git \
    python \
    python-dev \
    libpcre3 \
    libpcre3-dev \
    python-setuptools \
    python-pip \
    nginx \
    supervisor \
    default-libmysqlclient-dev \
    python-psycopg2 \
    libpq-dev \
    sqlite3 && \
    pip install -U pip setuptools && \
    rm -rf /var/lib/apt/lists/*

RUN pip install -r requirements.txt

EXPOSE 8000

RUN chmod +x entry_point.sh

docker-compose.yml 泊坞窗,compose.yml

version: "2"
services:
  db:
    restart: always
    container_name: docker_test-db
    image: postgres:9.6
    expose:
      - "5432"
    mem_limit: 10m
    environment:
      - POSTGRES_NAME=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=docker_test

  redis:
    restart: always
    image: redis:3.0
    expose:
      - "6379"
    mem_limit: 10m

  web:
    # replace username/repo:tag with your name and image details
    restart: always
    build: .
    image: docker_test
    container_name: docker_test-container
    ports:
      - "8000:8000"
    environment:
      - DATABASE=db
      - POSTGRES_NAME=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=docker_test
    mem_limit: 500m
    depends_on:
      - db
      - redis
    entrypoint: ./entry_point.sh
    command: gunicorn docker_test.wsgi:application -w 2 -b :8000 --timeout 120 --graceful-timeout 120 --worker-class gevent

  celery:
    image: docker_test
    container_name: docker_test-celery
    command: celery -A docker_test worker -l info
    links:
      - db
      - redis
    mem_limit: 10m
    depends_on:
      - web

  cbeat:
    image: docker_test
    container_name: docker_test-cbeat
    command: celery beat --loglevel=info
    links:
      - db
      - redis
    mem_limit: 10m
    depends_on:
      - web

I works file when I run it on my local system. 在本地系统上运行文件时,我会工作。 But when I upload it on elasticbeanstalk, It gives my following error. 但是,当我将其上传到elasticbeanstalk时,出现了以下错误。

ECS task stopped due to: Essential container in task exited. 由于以下原因,ECS任务已停止:退出了任务中的基本容器。 (celery: db: cbeat: web: CannotPullContainerError: API error (404): pull access denied for docker_test, repository does not exist or may require 'docker login' redis: ) (celery:db:cbeat:web:CannotPullContainerError:API错误(404):拒绝docker_test的访问权限,存储库不存在或可能需要'docker login'redis:)

I transform docker-compose.yml to Dockerrun.aws.json by using container-transform . 我通过使用container-transformDockerrun.aws.json docker-compose.yml转换为Dockerrun.aws.json For above file, my Dockerrun.aws.json is following. 对于上面的文件, Dockerrun.aws.json是我的Dockerrun.aws.json

{
    "AWSEBDockerrunVersion": 2,
    "containerDefinitions": [
        {
            "command": [
                "celery",
                "beat",
                "--loglevel=info"
            ],
            "essential": true,
            "image": "docker_test",
            "links": [
                "db",
                "redis"
            ],
            "memory": 10,
            "name": "cbeat"
        },
        {
            "command": [
                "celery",
                "-A",
                "docker_test",
                "worker",
                "-l",
                "info"
            ],
            "essential": true,
            "image": "docker_test",
            "links": [
                "db",
                "redis"
            ],
            "memory": 10,
            "name": "celery"
        },
        {
            "environment": [
                {
                    "name": "POSTGRES_NAME",
                    "value": "postgres"
                },
                {
                    "name": "POSTGRES_USER",
                    "value": "postgres"
                },
                {
                    "name": "POSTGRES_PASSWORD",
                    "value": "postgres"
                },
                {
                    "name": "POSTGRES_DB",
                    "value": "docker_test"
                }
            ],
            "essential": true,
            "image": "postgres:9.6",
            "memory": 10,
            "name": "db"
        },
        {
            "essential": true,
            "image": "redis:3.0",
            "memory": 10,
            "name": "redis"
        },
        {
            "command": [
                "gunicorn",
                "docker_test.wsgi:application",
                "-w",
                "2",
                "-b",
                ":8000",
                "--timeout",
                "120",
                "--graceful-timeout",
                "120",
                "--worker-class",
                "gevent"
            ],
            "entryPoint": [
                "./entry_point.sh"
            ],
            "environment": [
                {
                    "name": "DATABASE",
                    "value": "db"
                },
                {
                    "name": "POSTGRES_NAME",
                    "value": "postgres"
                },
                {
                    "name": "POSTGRES_USER",
                    "value": "postgres"
                },
                {
                    "name": "POSTGRES_PASSWORD",
                    "value": "postgres"
                },
                {
                    "name": "POSTGRES_DB",
                    "value": "docker_test"
                }
            ],
            "essential": true,
            "image": "docker_test",
            "memory": 500,
            "name": "web",
            "portMappings": [
                {
                    "containerPort": 8000,
                    "hostPort": 8000
                }
            ]
        }
    ],
    "family": "",
    "volumes": []
}

How can I resolve this problem? 我该如何解决这个问题?

Please push the image "docker_test" to either dockerhub or ECR for Beanstalk to pull image from. 请将映像“ docker_test”推送到dockerhub或ECR,以便Beanstalk从中提取映像。 Currently, it's on your local & the ECS agent doesn't know about it. 目前,它在您的本地上,而ECS代理对此一无所知。

  1. Tag & Push docker_test image to a registry like dockerhub & ECR. docker_test映像标记并推docker_test dockerhub和ECR等注册表。
  2. Update image repo URL in Dockerrun.aws.json . 更新Dockerrun.aws.json图像Dockerrun.aws.json URL。
  3. Allow Beanstalk to pull the image. 允许Beanstalk提取图像。

I'm not that familiar with EB, but I am pretty familiar with ECR and ECS. 我对EB不太熟悉,但是对ECR和ECS却很熟悉。

I usually get that error when I try pull an image from an empty repo on ECR, in other words the ECR repo was created but you havn't pushed any docker images to the repo yet. 当我尝试从ECR上的空存储库中提取映像时,通常会收到该错误,换句话说,已创建了ECR存储库,但您尚未将任何Docker映像推送到存储库。

This can also happen when you try pull an image from ECR and it can't find the version number of the image in the tag. 当您尝试从ECR提取图像并且在标签中找不到图像的版本号时,也会发生这种情况。 I suggest that you change your docker-compose.yml file to use the latest version of the images. 我建议您将docker-compose.yml文件更改为使用最新版本的图像。 This will mean that everywhere you mention the image docker_test you will need suffix it with ":latest" Something like this: 这意味着到处提及镜像docker_test的地方都需要在其后缀“:latest”,如下所示:

image: docker_test:latest

I will post my whole docker-compose.yml I made for you at the end of the reply. 我将在回复末尾发布我为您制作的整个docker-compose.yml。

I would suggest that you have a look at this doc: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker.container.console.html see the section:"Using Images from an Amazon ECR Repository" they explain how you can resolve the docker login issue. 我建议您看一下此文档: https : //docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker.container.console.html请参阅部分:“使用Amazon ECR存储库中的图像”他们解释了如何解决docker登录问题。

I hope that helps. 希望对您有所帮助。 Please reply if you have any questions regarding this. 如果对此有任何疑问,请回复。

version: "2"
services:
  db:
    restart: always
    container_name: docker_test-db
    image: postgres:9.6
    expose:
      - "5432"
    mem_limit: 10m
    environment:
      - POSTGRES_NAME=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=docker_test

  redis:
    restart: always
    image: redis:3.0
    expose:
      - "6379"
    mem_limit: 10m

  web:
    # replace username/repo:tag with your name and image details
    restart: always
    build: .
    image: docker_test:latest
    container_name: docker_test-container
    ports:
      - "8000:8000"
    environment:
      - DATABASE=db
      - POSTGRES_NAME=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=docker_test
    mem_limit: 500m
    depends_on:
      - db
      - redis
    entrypoint: ./entry_point.sh
    command: gunicorn docker_test.wsgi:application -w 2 -b :8000 --timeout 120 --graceful-timeout 120 --worker-class gevent

  celery:
    image: docker_test
    container_name: docker_test-celery
    command: celery -A docker_test worker -l info
    links:
      - db
      - redis
    mem_limit: 10m
    depends_on:
      - web

  cbeat:
    image: docker_test:latest
    container_name: docker_test-cbeat
    command: celery beat --loglevel=info
    links:
      - db
      - redis
    mem_limit: 10m
    depends_on:
      - web

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS 上的多容器 Docker - Multi-Container Docker on AWS Azure web-app - Django 应用程序的多容器单元未成功启动 - Azure web-app - Multi-container unit was not started successfully for Django app 在多容器Docker设置中运行Django迁移 - Running Django migrations in a multi-container Docker setup Azure 容器实例:从 Django+Nginx+Postgres 创建多容器组 - Azure Container Instances: Create a multi-container group from Django+Nginx+Postgres 将Django应用程序部署到Elasticbeanstalk:使用Pip安装软件包时出错 - Deploying Django app to Elasticbeanstalk: Error installing packages with Pip 多容器应用程序中无法访问的数据库容器 - django.db.utils.OperationalError:(2002,“无法连接到'db'(115)上的 MySQL 服务器”) - unreachable db container in a multi-container application - django.db.utils.OperationalError: (2002, “Can't connect to MySQL server on 'db' (115)”) ModuleNotFoundError:部署到ElasticBeanstalk时没有名为'django'的模块 - ModuleNotFoundError: No module named 'django' while deploying to ElasticBeanstalk AWS ElasticBeanstalk 多 Docker 部署失败 - AWS ElasticBeanstalk Multi-Docker Deployment Failure 使用ElasticBeanstalk在AWS上部署在Python 3.6上运行的Django项目 - Deploying Django project, running on Python 3.6, on AWS using ElasticBeanstalk AWS ElasticBeanstalk 未能部署 Django/Postgres 应用程序 - AWS ElasticBeanstalk failed to deploy Django/Postgres app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM