1

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?

Sunil Singh
  • 56
  • 1
  • 5
  • `docker run -p 8080:8080 -i -t f760520b2550` – Sachith Muhandiram Mar 25 '21 at 06:57
  • 1
    It gives the same error but adding another flag `-d` solves the issue. I used the command `docker run -d -p 8080:8080 -i -t f760520b2550` and it worked fine. I still don't see anything on 127.0.0.1:8080. Can you please tell me how can I `docker-compose up` it? I am following instructions from [here](https://github.com/OpenMined/PyGrid). Do I need to write my own docker-compose.yml? – Sunil Singh Mar 25 '21 at 07:06
  • I created a docker-compose.yml file as this: https://pastebin.com/jJuiuwdF and received the same error(https://pastebin.com/UtqYVpws) on doing `docker-compose up`. – Sunil Singh Mar 25 '21 at 07:15

3 Answers3

2

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.

Anton Menshov
  • 2,266
  • 14
  • 34
  • 55
1

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

Sachith Muhandiram
  • 2,819
  • 10
  • 45
  • 94
0

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

T. Raza
  • 11
  • 1