简体   繁体   English

Docker 部署总是失败——巨大的容器大小

[英]Docker deployment always fails - massive container size

We are trying to deploy a Flask Docker container to AWS Elastic Beanstalk, and the deployment and our website were working fine for a while.我们正在尝试将 Flask Docker 容器部署到 AWS Elastic Beanstalk,部署和我们的网站在一段时间内运行良好。 Our Docker container was massive (5GB) because we had more dependencies in requirements.txt than we were actually using sunce we initialized it with pip freeze in a non-virtual environment.我们的 Docker 容器很大 (5GB),因为我们在 requirements.txt 中的依赖项比实际使用的要多,因为我们在非虚拟环境中使用 pip freeze 对其进行了初始化。

We hit a problem with a library (Apache Tika was working normally locally, but we were getting an error on the deployment implying that we needed to install Java), so we tried adding Java installation to our Dockerfile.我们遇到了库问题(Apache Tika 在本地正常工作,但我们在部署时遇到错误,暗示我们需要安装 Java),因此我们尝试将 Java 安装添加到我们的 Dockerfile。 Since we have tried this, we cannot get anything to deploy on AWS, even our old repo.由于我们已经尝试过了,我们无法在 AWS 上部署任何东西,甚至是我们的旧存储库。 I've tried removing the Java installation as well as all the unnecessary pip dependencies from requirements.txt, but when we use "docker build" the old pip dependencies are STILL being installed and the Docker container is BIGGER, not smaller than before.我已经尝试从 requirements.txt 中删除 Java 安装以及所有不必要的 pip 依赖项,但是当我们使用“docker build”时,旧的 pip 依赖项仍在安装并且 Docker 容器更大,并不比以前小。

In the AWS EB logs, there is no application logs file since the deployment fails, but we see errors like: -2022/12/19 19:56:18.408872 [ERROR] An error occurred during execution of command [app-deploy] - [Docker Specific Build Application].在 AWS EB 日志中,没有应用程序日志文件,因为部署失败,但我们看到如下错误:-2022/12/19 19:56:18.408872 [ERROR] An error occurred during execution of command [app-deploy] - [Docker 特定构建应用程序]。 Stop running the command.停止运行命令。 Error: failed to pull docker image: Command /bin/sh -c docker pull URL.dkr.ecr.us-east-1.amazonaws.com/url-path:latest failed with error Command timed out after 300 seconds -2022/12/19 19:56:18.728922 [INFO] CommandService Response: {"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine execution has encountered an error.","returncode":1,"events":[{"msg":"Instance deployment failed to download the Docker image. The deployment failed.","timestamp":1671479778249,"severity":"ERROR"},{"msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1671479778487,"severity":"ERROR"}]}]}错误:拉取 docker 镜像失败:命令 /bin/sh -c docker pull URL.dkr.ecr.us-east-1.amazonaws.com/url-path:latest failed with error 命令在 300 秒后超时 -2022/ 12/19 19:56:18.728922 [INFO] 命令服务响应:{“status”:“FAILURE”,“api_version”:“1.0”,“results”:[{“status”:“FAILURE”,“msg”:”引擎执行遇到错误。","returncode":1,"events":[{"msg":"实例部署下载Docker镜像失败,部署失败。","timestamp":1671479778249,"severity" :"ERROR"},{"msg":"实例部署失败。详情请查看'eb-engine.log'。","timestamp":1671479778487,"severity":"ERROR"}]}]}

Our Dockerfile looks like:我们的 Dockerfile 看起来像:

FROM python:3.9

# Set the working directory and install the requirements
WORKDIR /server
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt

# Expose port 5000 and copy the source code
EXPOSE 5000
COPY . .

# Run the application using gunicorn
CMD ["gunicorn", "wsgi:app", "-w 2", "-b 0.0.0.0:5000", "-t 30"]

What we have tried:我们尝试过的:

Question:题:

What could be causing the massive size of the Docker container?是什么导致了 Docker 容器的巨大尺寸? How can we resolve this issue and successfully deploy the Docker container to AWS Elastic Beanstalk?我们如何解决这个问题并成功地将 Docker 容器部署到 AWS Elastic Beanstalk?

We solved this by extending the timeout in the Elastic Beanstalk config.yml.我们通过延长 Elastic Beanstalk config.yml 中的超时解决了这个问题。

aws:elasticbeanstalk:command:
      timeout: 900

This still doesn't explain why old pip dependencies that we got rid of are being installed in new Docker builds though so anyone who could answer that would be appreciated and accepted as the answer.这仍然不能解释为什么我们摆脱的旧 pip 依赖项被安装在新的 Docker 构建中,所以任何能够回答这个问题的人都会受到赞赏并被接受为答案。

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

相关问题 无法在 Cloud Run 部署中列出容器映像 - Unable to list the Container images in Cloud Run deployment Quarkus 部署到 Google Cloud App 引擎失败 - Quarkus deployment to Google Cloud App engine fails Gitlab Docker 容器中的防火墙设置 - Firewall settings in a Gitlab Docker container AWS SFN JSONpath 在数据流中工作但在部署时失败 - AWS SFN JSONpath works in dataflow but fails on deployment GitLab Docker-in-Docker:作业容器中的 Docker 客户端如何发现“dind”服务容器中的 Docker 守护进程? - GitLab Docker-in-Docker: how does Docker client in job container discover Docker daemon in `dind` service container? Cron 总是失败,手动执行总是成功。 如何? - Cron always fails and manual execution always succeeds. How? xwininfo -tree 总是在 lambda 容器上显示 0 个孩子 - xwininfo -tree always shows 0 children on lambda container 如何在 azure 容器应用程序上托管 arm64 docker 容器 - How to host a arm64 docker container on azure container apps Cloud Run 中 Docker 容器上的 POST 出现 405 错误 - 405 error for POST on Docker Container in Cloud Run Jenkins 在 Docker 容器中运行但无法在浏览器上启动它 - Jenkins running in Docker Container but unable to launch it on browser
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM