guppythegod
guppythegod

Reputation: 63

AWS Elastic Beanstalk and Docker - EXPOSE requires at least one argument

Ive been trying to deploy my docker image to AWS beanstalk for the past couple days and encountered this problem which I couldn't find a solution for. When I upload my Dockerrun.aws.json file to my environment (through the console), it throws this error

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.

The weird thing is that in my Dockerfile my EXPOSE keyword includes port 80 as an argument.

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"
     }
 }

Here's a link to my image on Docker hub: https://hub.docker.com/r/guppythegod/racheal_entrance_gateway

All my permissions are working and the repository that holds my image is public. If anyone can help me out, it will be greatly appreciated.

Thank You.

Upvotes: 1

Views: 1078

Answers (2)

Aravinth Raja
Aravinth Raja

Reputation: 429

Setting the ENV Port number solved my issue, and one more tip do git commit the changes before you do deployment eb deploy

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;"]

Upvotes: 2

jrc
jrc

Reputation: 21939

Ports should be an array, like this:

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

Upvotes: 3

Related Questions