Jupyterhub: Port exposed by Docker not reachable

Created on 22 Nov 2016  路  2Comments  路  Source: jupyterhub/jupyterhub

I have asked this on StackOverflow but this could be a better channel.

How to reproduce the issue
Build an image based on this Dockerfile

FROM continuumio/miniconda3
RUN apt-get install -y npm nodejs-legacy && \
    npm install -g configurable-http-proxy && \
    pip install jupyterhub dockerspawner jupyter_client
EXPOSE 8000
CMD jupyterhub --no-ssl

then run docker run -t tmp

What you expected to happen
127.0.0.1:8000 is accessible from outside the container

What actually happens
127.0.0.1:8000 is not accessible from browsers.

docker ps shows that port 8000 is open.

~ docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
7e51cdf9f234        tmp                 "/usr/bin/tini -- /bi"   7 seconds ago       Up 5 seconds        8000/tcp            boring_chandrasekhar

netstat doesn't agree.

~ netstat -lt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 *:ssh                   *:*                     LISTEN
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN

Most helpful comment

Hi @FabHan. Even though you EXPOSE port 8000 in your Dockerfile, you still need to map it to an external port at runtime with a command like docker run -p 8000:8000 -t tmp.

The EXPOSE in the Dockerfile only enables you to use the shorthand docker run -t -P tmp where the capital P tells docker to automatically map all exposed ports to external ports.

All 2 comments

Hi @FabHan. Even though you EXPOSE port 8000 in your Dockerfile, you still need to map it to an external port at runtime with a command like docker run -p 8000:8000 -t tmp.

The EXPOSE in the Dockerfile only enables you to use the shorthand docker run -t -P tmp where the capital P tells docker to automatically map all exposed ports to external ports.

Thank you. That solves my problem.

Was this page helpful?
0 / 5 - 0 ratings