Docker Community Forums

Share and learn in the Docker community.

Unable to access application from web

Hi team,

I have below docker file , it ran successfully, but expose port is not working.

FROM continuumio/miniconda3
LABEL maintainer=“https://github.ibm.com/security-think-tank/ara_nist

WORKDIR /code
COPY . /code

RUN conda env create -f=environment.yml
RUN /bin/bash -c “source /opt/conda/etc/profile.d/conda.sh &&
conda activate aranist &&
source /code/environment.sh”

EXPOSE 8000
ENTRYPOINT [ “/bin/bash” , “-c” ]

if I build the container using
docker build -t tss_ml .
and run using
docker run -p 8000:8050 tss_ml ‘source /code/run_aranist.sh’
I get this
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [35]
INFO: Started server process [37]
INFO: Waiting for application startup.
INFO: Application startup complete.
which looks great, but I can’t access via my browser.
I’ve tried
127.0.0.1:8000
localhost:8000
0.0.0.0:8000
but none of them seem to work

The EXPOSE command doesn’t do anything, this is just a hint. You publish port 8050 of the application to port 8000 on localhost. Are you sure it is actually running on 8050? If I look at the Dockerfile for miniconda3 it seems to me it runs on 8888.
And something else: The source command in the Dockerfile is only executed while you build the image. Is this what you wanted?

Thanks Tekki for quick reply.

Could you guide me how docker file should look like in my case.Thanks

no changes has been done only in command which is replace with 8000 to 8888, and if my application is running on 8050 then it should run.please correct me.Thanks

127.0.0.1:8888

FROM continuumio/miniconda3
LABEL maintainer=“https://github.ibm.com/security-think-tank/ara_nist”

WORKDIR /code
COPY . /code

RUN conda env create -f=environment.yml
RUN /bin/bash -c “source /opt/conda/etc/profile.d/conda.sh &&
conda activate aranist &&
source /code/environment.sh”

EXPOSE 8000
ENTRYPOINT [ “/bin/bash” , “-c” ]


docker build -t tss_ml .

docker run -p 8888:8050 tss_ml ‘source /code/run_aranist.sh’

I’ve actually not much time to spend in this forum, so don’t expect too much help.
What I don’t understand is where this port 8050 comes from. If you didn’t manipulate the miniconda3 image then the application inside the container runs on 8888. This means if you want to access it at 8000 on localhost you have to use the parameter -p 8000:8888.