gpt4 book ai didi

python - aws docker 中没有 EXPOSE 部署失败

转载 作者:太空宇宙 更新时间:2023-11-04 10:21:02 24 4
gpt4 key购买 nike

我有一个 scrapy 项目,通过托管在 docker 镜像中的 cron 持续运行。

当我在本地运行和部署它时,一切正常。如果我尝试将其部署到 AWS,我会在日志中收到以下错误:

No EXPOSE directive found in Dockerfile, abort deployment (ElasticBeanstalk::ExternalInvocationError)

控制台显示我的容器构建正确,但如果没有 EXPOSED 端口我就无法使用它。

INFO: Successfully pulled python:2.7
WARN: Failed to build Docker image aws_beanstalk/staging-app, retrying...
INFO: Successfully built aws_beanstalk/staging-app
ERROR: No EXPOSE directive found in Dockerfile, abort deployment
ERROR: [Instance: i-6eebaeaf] Command failed on instance. Return code: 1 Output: No EXPOSE directive found in Dockerfile, abort deployment.
Hook /opt/elasticbeanstalk/hooks/appdeploy/enact/00run.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
INFO: Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].

但为什么不可能呢?

我的 Dockerfile 如下所示:

FROM python:2.7
MAINTAINER XDF

ENV DIRECTORY /opt/the-flat

# System
##########

RUN apt-get update -y && apt-get upgrade -y && apt-get install -y ntp vim apt-utils
WORKDIR $DIRECTORY

# GIT
##########
# http://stackoverflow.com/questions/23391839/clone-private-git-repo-with-dockerfile

RUN apt-get install -y git
RUN mkdir /root/.ssh/
ADD deploy/git-deply-key /root/.ssh/id_rsa
RUN chmod 0600 /root/.ssh/id_rsa
RUN touch /root/.ssh/known_hosts
RUN ssh-keyscan -t rsa bitbucket.org >> /root/.ssh/known_hosts
RUN ssh -T -o 'ConnectionAttempts=1' git@bitbucket.org
RUN git clone --verbose git@bitbucket.org:XDF/the-flat.git .

# Install
##########

RUN pip install scrapy
RUN pip install MySQL-python

# not working
# apt-get install -y wkhtmltopdf && pip install pdfkit
# else
# https://pypi.python.org/pypi/pdfkit

RUN DEBIAN_FRONTEND=noninteractive apt-get install -y openssl build-essential xorg libssl-dev
RUN wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.10.0_rc2-static-amd64.tar.bz2
RUN tar xvjf wkhtmltopdf-0.10.0_rc2-static-amd64.tar.bz2
RUN chown root:root wkhtmltopdf-amd64
RUN mv wkhtmltopdf-amd64 /usr/bin/wkhtmltopdf
RUN pip install pdfkit

# Cron
##########
# http://www.ekito.fr/people/run-a-cron-job-with-docker/
# http://www.corntab.com/pages/crontab-gui

RUN apt-get install -y cron
RUN crontab "${DIRECTORY}/deploy/crontab"

CMD ["cron", "-f"]

最佳答案

这是设计使然。您需要在 Dockerfile 中有一个 EXPOSE 端口指令来告诉 beanstalk 您的应用程序将监听哪个端口。您是否有不能或不想在 Dockerfile 中使用 EXPOSE 的用例?

关于python - aws docker 中没有 EXPOSE 部署失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32294605/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com