过去几天我一直试图将我的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
我的所有权限都在运行,保存我图片的存储库是公开的。如果有人能帮助我,我们将不胜感激。
谢谢。
答案 0 :(得分:3)
Ports
应该是一个数组,如下所示:
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "guppythegod/racheal_entrance_gateway:latest",
"Update": "true"
},
"Ports": [
{
"ContainerPort": "80"
}
]
}
答案 1 :(得分:0)
设置ENV端口号解决了我的问题,在部署eb deploy
之前,另一个提示是git提交所做的更改
DockerFile
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;"]