简体   繁体   English

Docker 容器在使用 AWS ECR 的 AWS ECS 中不起作用

[英]Docker Container not working in AWS ECS using AWS ECR

I've single docker container and have to deploy on AWS Cloud using AWS ECR with Elastic Beanstalk.我有单个 docker 容器,并且必须使用带有 Elastic Beanstalk 的 AWS ECR 部署在 AWS 云上。 I'm using Dockerrun.aws.json file to provide the information about repository details.我正在使用Dockerrun.aws.json文件来提供有关存储库详细信息的信息。 I have pushed my image to my docker hub and Elastic Container Registry.我已将我的图像推送到我的 docker 集线器和 Elastic Container Registry。

Using DockerHub in ECS, It can pull the docker image from docker hub and starts the container without any issues and working the app as expected.在 ECS 中使用 DockerHub,它可以从 docker 集线器中提取 docker 映像,并在没有任何问题的情况下启动容器并按预期运行应用程序。 On the other hand, the container gets stopped when the image pulled from AWS ECR Repository for the same application.另一方面,当从同一应用程序的 AWS ECR 存储库中提取映像时,容器会停止。 The deployment gets failed for the reason: Essential container in task exited部署失败的原因是: Essential container in task exited

Dockerrun.aws.json

{
    
    "containerDefinitions": [
        {
            "essential": true,
            "image": "01234567891.dkr.ecr.us-east-1.amazonaws.com/app:1",
            "memory": 512,
            "name": "web",
            "portMappings": [
                {
                    "containerPort": 5000,
                    "hostPort": 80
                }
            ]
        }
    ],
    "family": "",
    "volumes": [],
    "AWSEBDockerrunVersion": "2"
}

I logged into the instance and tried to get the logs of the containers.我登录到实例并尝试获取容器的日志。 But, I got this error standard_init_linux.go:211: exec user process caused "exec format error"但是,我收到了这个错误standard_init_linux.go:211: exec user process caused "exec format error"

Dockerfile

FROM python:3.4-alpine
ADD . /code
WORKDIR /code
RUN pip install -r requirements.txt
CMD ["python", "app.py"]

Seems like there is depended on docker container in task definition or the docker-compose file.似乎在任务定义或 docker-compose 文件中depended on docker 容器。

This error occur you have container B that is opened on A and A is esetional for services, so container B will automatically exit.发生此错误时,您在A上打开了容器B ,并且A对服务是重要的,因此容器B将自动退出。

You need to debug why A is exit.您需要调试为什么A退出。

Essential container in task exited任务中的基本容器已退出

If a container marked as essential in task definitions exits or dies, that can cause a task to stop.如果在任务定义中标记为必需的容器退出或死亡,则可能导致任务停止。 When an essential container exiting is the cause of a stopped task, the Step 6 can provide more diagnostic information as to why the container stopped.当必要的容器退出是任务停止的原因时, 步骤 6可以提供更多关于容器停止原因的诊断信息。

stopped-task-errors 停止任务错误

The problem lies in AWS CodeBuild Project.问题在于 AWS CodeBuild 项目。 I've mistakenly provided the wrong architecture for the build.我错误地为构建提供了错误的架构。 The docker image built on different architecture and tried to run on the different architecture in the deployment state. docker 镜像建立在不同的架构上,并在部署 state 中尝试在不同的架构上运行。 I've changed to the same architecture which is used for the deployment.我已更改为用于部署的相同架构。 Both the docker hub image and ECR image seems working fine. docker 集线器图像和 ECR 图像似乎工作正常。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM