简体   繁体   中英

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. 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.

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. Since we have tried this, we cannot get anything to deploy on AWS, even our old repo. 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.

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]. 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"}]}]}

Our Dockerfile looks like:

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? How can we resolve this issue and successfully deploy the Docker container to AWS Elastic Beanstalk?

We solved this by extending the timeout in the 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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