【问题标题】:AWS Elastic Beanstalk and Docker - EXPOSE requires at least one argumentAWS Elastic Beanstalk 和 Docker - EXPOSE 至少需要一个参数
【发布时间】:2018-09-18 05:48:54
【问题描述】:

在过去的几天里,我一直在尝试将我的 docker 映像部署到 AWS beanstalk,但遇到了这个我找不到解决方案的问题。当我将 Dockerrun.aws.json 文件上传到我的环境(通过控制台)时,它会引发此错误

Failed to build Docker image aws_beanstalk/staging-app: Sending build context to Docker daemon 3.072kB Error response from daemon: Dockerfile parse error line 2: EXPOSE requires at least one argument. Check snapshot logs for details.

奇怪的是,在我的 Dockerfile 中,我的 EXPOSE 关键字包含端口 80 作为参数。

Dockerfile:

FROM ubuntu

EXPOSE 80

ADD application.py /application.py
ADD requirements.txt /requirements.txt

RUN apt-get update
RUN apt-get -y install sudo

RUN sudo apt-get -y install python3-pip

# INSTALLING GCC
# RUN sudo apt-get -y install gcc

# DEPENDENCY INSTALATION
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install -r ./requirements.txt

# SPACY ENGLISH MODEL DOWNLOAD
RUN python3 -m spacy download en

CMD ["python3", "./application.py"]

Dockerrun.aws.json:

 {
     "AWSEBDockerrunVersion": "1",
     "Image" : {
      "Name" : "guppythegod/racheal_entrance_gateway:latest",
       "Update" : "true"
     },
     "Ports" : {
       "ContainerPort" : "80"
     }
 }

这是我在 Docker hub 上的图片的链接: https://hub.docker.com/r/guppythegod/racheal_entrance_gateway

我的所有权限都有效,并且保存我的图像的存储库是公开的。如果有人可以帮助我,将不胜感激。

谢谢。

【问题讨论】:

    标签: amazon-web-services docker elasticsearch amazon-elastic-beanstalk dockerfile


    【解决方案1】:

    Ports 应该是一个数组,像这样:

    {
      "AWSEBDockerrunVersion": "1",
      "Image": {
        "Name": "guppythegod/racheal_entrance_gateway:latest",
        "Update": "true"
      },
      "Ports": [
        {
          "ContainerPort": "80"
        }
      ]
    }
    

    【讨论】:

    • 这个答案为我们的团队节省了一天。
    【解决方案2】:

    设置 ENV 端口号解决了我的问题,还有一个技巧是在部署之前 git commit the changes eb deploy

    Docker 文件

    FROM node:alpine AS builder
    
    WORKDIR /opt/app
    
    COPY package.json  ./
    
    RUN npm install
    
    COPY . /opt/app
    
    RUN npm run build
    
    FROM nginx
    
    COPY --from=builder /opt/app/build /usr/share/nginx/html
    
    ENV PORT 80
    EXPOSE 80
    
    CMD ["nginx", "-g", "daemon off;"]
    

    【讨论】:

      猜你喜欢
      • 2017-11-16
      • 1970-01-01
      • 2020-04-08
      • 1970-01-01
      • 2011-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-11
      相关资源
      最近更新 更多