Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python aws docker中没有公开无法部署_Python_Amazon Web Services_Amazon Elastic Beanstalk_Dockerfile - Fatal编程技术网

Python aws docker中没有公开无法部署

Python aws docker中没有公开无法部署,python,amazon-web-services,amazon-elastic-beanstalk,dockerfile,Python,Amazon Web Services,Amazon Elastic Beanstalk,Dockerfile,我有一个由cron在docker映像中持续运行的scrapy项目 当我在本地运行和部署它时,一切正常。如果我尝试将其部署到AWS,则在日志中会出现以下错误: No EXPOSE directive found in Dockerfile, abort deployment (ElasticBeanstalk::ExternalInvocationError) 控制台显示我的容器构建正确,但如果没有暴露的端口,我就无法使用它 INFO: Successfully pulled python:2.

我有一个由cron在docker映像中持续运行的scrapy项目

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

No EXPOSE directive found in Dockerfile, abort deployment (ElasticBeanstalk::ExternalInvocationError)
控制台显示我的容器构建正确,但如果没有暴露的端口,我就无法使用它

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 port指令来告诉beanstalk你的应用程序将监听哪个端口。您是否有一个不能或不想在Dockerfile中公开的用例?

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

ElasticBeanstalk是为web应用程序设计的,因此需要公开。您演示的用例是jobs(workers)服务器,Elastic Beanstalk无法很好地处理该服务器。

对于您的情况,要么公开一个虚拟端口号,要么自己启动一个EC2实例以绕过EB过载。

ElasticBeanstalk是为web应用程序设计的,因此需要公开。您演示的用例是jobs(workers)服务器,Elastic Beanstalk无法很好地处理该服务器。

对于您的情况,要么公开一个虚拟端口号,要么自己启动一个EC2实例以绕过EB过载。

遗憾的是,我的scrapy crawler只是获取数据并将其存储到数据库中。所以不需要曝光。现在,我只是暴露了一个随机端口,它工作了。。但为什么需要它呢?通常,这是针对作为Web应用程序结构的应用程序。Worker tier也被设计为Web应用程序,即使该端口仅在localhost上为Worker tier打开。@RohitBanga我们在Elastic Beanstalk中运行Worker已有几年了,它们不公开端口——它们连接到队列服务并处理消息。对于工作层容器来说,公开端口的要求是愚蠢的。作为一种解决方法,我们必须公开一些端口,即使它不会被使用。它只在localhost上公开,因为工作层守护进程正在您的容器外运行。很遗憾,是的,我的scrapy crawler只是获取数据并将其存储到数据库中。所以不需要曝光。现在,我只是暴露了一个随机端口,它工作了。。但为什么需要它呢?通常,这是针对作为Web应用程序结构的应用程序。Worker tier也被设计为Web应用程序,即使该端口仅在localhost上为Worker tier打开。@RohitBanga我们在Elastic Beanstalk中运行Worker已有几年了,它们不公开端口——它们连接到队列服务并处理消息。对于工作层容器来说,公开端口的要求是愚蠢的。作为一种解决方法,我们必须公开某些端口,即使它不会被使用。它仅在localhost上公开,因为工作层守护程序正在容器外部运行。是否也有工作(Cronjob)触发的实例类型?是否也有工作(Cronjob)触发的实例类型?