简体   繁体   English

AWS docker中没有EXPOSE会使部署失败

[英]No EXPOSE in aws docker fails deployment

I have a scrapy project run continously by cron hosted inside a docker image. 我有一个由cron托管在docker映像中的连续项目。

When I run and deploy this locally everything works fine. 当我在本地运行和部署此程序时,一切正常。 If I try to deploy the same to AWS I get the following error inside the logs: 如果我尝试将其部署到AWS,则会在日志中收到以下错误:

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

The console shows that my container was build correctly but I can not use it without an EXPOSED port. 控制台显示我的容器是正确构建的,但是没有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].

But why is it not possible? 但是为什么不可能呢?

My Dockerfile looks like the following: 我的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"]

It's by design. 这是设计使然。 You need to have an EXPOSE port directive in your Dockerfile to tell beanstalk what port your app will be listening on. 您需要在Dockerfile中有一个EXPOSE端口指令,以告诉beantalk您的应用程序将侦听哪个端口。 Do you have a usecase where you cannot or do not want to have EXPOSE in your Dockerfile? 您是否有一个用例,您无法或不希望在Dockerfile中使用EXPOSE?

ElasticBeanstalk is designed for web applications, hence the EXPOSE requirement. ElasticBeanstalk是为Web应用程序设计的,因此是EXPOSE要求。 The use case you demonstrated is that of a jobs (workers) server, which Elastic Beanstalk doesn't handle well. 您演示的用例是工作服务器(工作服务器),Elastic Beanstalk处理得不好。
For your case, either expose a dummy port number or launch an EC2 instance yourself to bypass the EB overload. 对于您的情况,可以公开一个虚拟端口号,或者自己启动EC2实例以绕过EB重载。

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

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