Question

In droplet : My Docker running a Flask server on port 6000 is not accessible outside

Posted June 18, 2021 215 views
DigitalOcean Droplets

Hello guys,

I have an issue with a droplet.

When I run my docker on host 0.0.0.0 and on port 6000
It seems it is not accessible when I do <public ip address>:6000

Although, following the tutorial here, I have ran the commands below :
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw enable
sudo ufw allow 6000/tcp

Does someone knows if the port 6000 is allowed to be used in DO or I forgot to configure something ?

Below the dockerfile :

FROM python:3.8.1

ENV FLASK_APP=nace_recommender.api.app:app
ENV FLASK_ENV=development
ENV WORKERS=4

RUN useradd -b /home -U banana && mkdir -p /home/banana/app
COPY . /home/banana/app
RUN chown -R banana:banana /home/banana
USER banana

# set working directory
WORKDIR /home/banana/app

RUN pip install -r requirements.txt 

EXPOSE 6000

CMD /home/banana/.local/bin/gunicorn --preload -w $WORKERS -b 0.0.0.0:6000 "nace_recommender.api.app:app()" -t 60

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi there,

The Dockerifle that you’ve shared indicates that the service will listen on port 6000 inside the container itself.

Note that you would need to use the -p 6000:6000 flag and expose the container port to the host.

Then in order to check if the port is exposed correctly on the host you could run the following command:

netstat -plant | grep

Let me know how it goes!
Regards,
Bobby