Sunil Singh
Sunil Singh

Reputation: 46

docker run gives Error: '' is not a valid port number

I am new to docker, trying to run a pulled docker image.

docker images gives this:

REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE
openmined/grid-network   development         f760520b2550        8 days ago          785MB
openmined/grid-node      development         89a4d0202703        8 days ago          3.48GB

I ran the pulled images following this link, by using command: docker run -i -t f760520b2550 but found this error:

Error: '' is not a valid port number.

I tried playing with the flags like docker run -i -t f760520b2550 -p 8080:8080, but didn't help. I have only installed docker recently and have done no changes in configurations. Can someone help me with this error?

Upvotes: 1

Views: 3745

Answers (3)

T. Raza
T. Raza

Reputation: 11

For this problem you can just bind port to 8080 like I am giving an example

In Dockerfile:

FROM python:3.7

COPY . /app

WORKDIR /app

RUN pip install -r requirements.txt

EXPOSE $PORT

CMD gunicorn --workers=1 --bind 0.0.0.0:8080 application:application

And then in terminal use : (Pass your image id in place of IMAGE ID below)

docker run -p 8080:8080 -e PORT=8080 IMAGE ID

Upvotes: 0

Tariq Haque
Tariq Haque

Reputation: 21

I faced a similar problem working with a docker image. What worked for me was making the following change in the dockerfile to build the docker image with --bind 0.0.0.0:8080 instead of --bind :$PORT

--bind :$PORT does work in a cloud build, but doesn't work in a docker run.

Don't know the reason.

Upvotes: 2

Sachith Muhandiram
Sachith Muhandiram

Reputation: 2972

To expose ports using docker-compose

version: '3'
services:
  grid-network:
    image: openmined/grid-network:development
    ports: 
      - "8080:8080"
      - "8001:8001"

Then docker-compose up -d

Upvotes: 1

Related Questions