Elastic Beanstalk在Docker-Compose上看不到公开的端口

我有一个凤凰应用程序,我试图推动AWS /弹性beanstalk。

现在我遵循这个指南,并确认Docker-compose和run命令在localhost https://github.com/dreamingechoes/docker-elixir-phoenix上工作 。

但是,我很难通过eb cli接口将项目部署到弹性beanstalk。

这是运行后得到的错误

eb create projectName

 ERROR: No EXPOSE directive found in Dockerfile, abort deployment ERROR: [Instance: i-0cabfeaad7423be93] Command failed on instance. Return code: 1 Output: No EXPOSE directive found in Dockerfile, abort deployment. 

我的文件:

Dockerfile:

 # Versions # # Erlang: 1:20.0 # Elixir: 1.5.0 # Phoenix: 1.3.0 FROM ubuntu:14.04 ENV DEBIAN_FRONTEND noninteractive # Elixir requires UTF-8 RUN locale-gen en_US.UTF-8 ENV LANG en_US.UTF-8 ENV LANGUAGE en_US:en ENV LC_ALL en_US.UTF-8 RUN apt-get update && apt-get upgrade -y && \ apt-get install -y sudo wget curl inotify-tools git build-essential zip unzip # Install Node.js (>= 5.0.0) and NPM in order to satisfy brunch.io dependencies # See http://www.phoenixframework.org/docs/installation#section-node-js-5-0-0- RUN curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - && apt-get install -y nodejs # Download and install Erlang package RUN wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb \ && dpkg -i erlang-solutions_1.0_all.deb \ && apt-get update ENV ERLANG_VERSION 1:20.0 # Install Erlang RUN apt-get install -y esl-erlang=$ERLANG_VERSION && rm erlang-solutions_1.0_all.deb ENV ELIXIR_VERSION 1.5.0 # Install Elixir RUN mkdir /opt/elixir \ && cd /opt/elixir \ && curl -O -L https://github.com/elixir-lang/elixir/releases/download/v$ELIXIR_VERSION/Precompiled.zip \ && unzip Precompiled.zip \ && cd /usr/local/bin \ && ln -s /opt/elixir/bin/elixir \ && ln -s /opt/elixir/bin/elixirc \ && ln -s /opt/elixir/bin/iex \ && ln -s /opt/elixir/bin/mix ENV PHOENIX_VERSION 1.3.0 # Install the Phoenix Mix archive RUN mix archive.install --force https://github.com/phoenixframework/archives/raw/master/phx_new-$PHOENIX_VERSION.ez # Install hex & rebar RUN mix local.hex --force && \ mix local.rebar --force && \ mix hex.info #EXPOSE 4000 WORKDIR /newsly_project CMD ["./startproj.sh"] 

startproj.sh文件只是启动应用程序所需的docker-compose命令(包括必要的bash引用):

 #!/bin/bash docker-compose build web docker-compose run web mix deps.get docker-compose run web mix ecto.create docker-compose run web mix ecto.migrate docker-compose run web npm install docker-compose up 

同样,docker-compose.yml文件应该来自示例:

 version: '2' services: db: image: postgres:9.5 web: build: . command: mix phx.server volumes: - .:/newsly_project ports: - "4000:4000" depends_on: - db 

在这里我公开了这个端口,但是不要在Dockerfile中这样做,因为它应该在这里处理(这是我在本地运行docker-compose文件时运行的)。

Dockerfile.aws.json(这几乎是从这里的例子逐字: http ://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_image.html)

 { "AWSEBDockerrunVersion": "1", "Image": { "Name": "newsly_image", "Update": "true" }, "Ports": [ { "ContainerPort": "4000" } ], "Volumes": [ { "HostDirectory": "/var/app/mydb", "ContainerDirectory": "/etc/mysql" } ], "Logging": "/var/log/nginx" } 

当遇到这个问题时,这个问题由AWS的这个博客

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/troubleshooting-docker.html

说这个问题是在Dockerrun文件中没有正确定义端口。 不过,我看起来就像这个例子。

去我的SSH日志

 [ec2-user@ip-172-31-40-182 ~]$ less /var/log/eb-docker/containers/eb-current-app/unexpected-quit.log /var/log/eb-docker/containers/eb-current-app/unexpected-quit.log: No such file or directory 

现在,如果我在EXPOSE 4000取消注释EXPOSE 4000语句(这应该没有意义,因为端口处理应该通过docker-compose完成),我得到以下错误:

 ERROR: Docker container quit unexpectedly after launch: Docker container quit unexpectedly on Tue Nov 14 04:27:11 UTC 2017:. Check snapshot logs for details. ERROR: [Instance: i-0e28d8f4d762b8c26] Command failed on instance. Return code: 1 Output: 8687081cc4e8687684adac75366b1433702284b5a71f4455d656605ea9ccd603 Docker container quit unexpectedly after launch: Docker container quit unexpectedly on Tue Nov 14 04:27:11 UTC 2017:. Check snapshot logs for details. 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]. ERROR: Create environment operation is complete, but with errors. For more information, see troubleshooting documentation. 

如果我再次查看eb ssh日志,我发现日志现在存在,但是是空的。

所以这是我的问题:

看起来,尽pipe有一个docker-compose文件,弹性beanstalk似乎是在我的Dockerfile中search公开的端口(这破坏了我的应用程序 – 这不应该太令人吃惊,因为它没有被configuration为以这种方式使用)。 尽pipe使用了几乎所有的Dockerrun.aws.json文件样板文字示例, 我做错了什么,应该是非常明显的? 我为这个问题表示歉意,但是我一直在join和减去不同文件中的端口,我已经达到了我只是盲目猜测的地步。

这里是从运行eb create projectName完整的terminal列表

 patientplatypus@next ~/Desktop/newsly_project $ eb create newslyproduction12 Creating application version archive "app-92fc-171113_232722". Uploading: [##################################################] 100% Done... Environment details for: newslyproduction12 Application name: newsly_project Region: us-west-2 Deployed Version: app-##################### Environment ID: e-m3fekdtdfr Platform: arn:aws:elasticbeanstalk:us-west-2::platform/Docker running on 64bit Amazon Linux/2.7.4 Tier: WebServer-Standard CNAME: UNKNOWN Updated: 2017-11-14 05:28:05.321000+00:00 Printing Status: INFO: createEnvironment is starting. INFO: Using elasticbeanstalk-us-west-2-############ as Amazon S3 storage bucket for environment data. INFO: Created security group named: s######################## INFO: Created load balancer named: ############################### INFO: Created security group named: ################################## INFO: Created Auto Scaling launch configuration named: ############################################### INFO: Created Auto Scaling group named: #####################################vv INFO: Waiting for EC2 instances to launch. This may take a few minutes. INFO: Created Auto Scaling group policy named: ############################ INFO: Created Auto Scaling group policy named: ################################# INFO: Created CloudWatch alarm named: ################################# INFO: Created CloudWatch alarm named: ################################# INFO: Successfully pulled ubuntu:14.04 INFO: Successfully built aws_beanstalk/staging-app ERROR: No EXPOSE directive found in Dockerfile, abort deployment ERROR: [Instance: i-0cabfeaad7423be93] 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]. ERROR: Create environment operation is complete, but with errors. For more information, see troubleshooting documentation. 

编辑:

当我暴露在Dockerfile的端口,它确实给我错误,我应该检查活动日志。 当我查看那个日志时,我得到一条线,在Docker停止并尝试重新启动的时候,发生了一堆错误。

错误是这样开始的:

 <blahblahblah>[Initialization/PreInitStage0/PreInitHook/01setup-docker-options.sh]: Completed Activity. Result: Stopping docker: [ OK ] INFO: Volume group backing root filesystem could not be determined Checking that no-one is using the disk right now ... OK sfdisk: /dev/xvdcz: unrecognized partition table type sfdisk: no partitions found 

我已经开始在网上查找,但据我所知,这似乎是一个相当新颖的错误。