Docker Community Forums

Share and learn in the Docker community.

Docker expose and status


My Docker ports and status aren’t working well. It doesn’t publish ports and status always exit.

I’ve used these commands:
docker build -t sample-app-image .
docker run -d -P sample-app-image
docker run -d -p 8080:80 --name pythontest sample-app-image

FROM python
WORKDIR /home/ubuntu
COPY ./ /home/ubuntu/.
RUN pip install flask
CMD python /home/ubuntu/

Presumably this starts a Flask server that keeps running. But: does it? I doubt it, as all containers show Exited.

If Flask is running on port 8080, then your -p 8080:80 is wrong. That publishes the container’s port 80 to the local port 8080; you may have wanted -p 8080:80 instead.

All said, I don’t know why you’re not seeing the ports in docker ps. (I don’t think Docker checks if anything is actually listening to the published ports, and it should even show the ports for stopped containers, I think.)

Docker won’t show the published ports for stopped containers, so you need to make sure that your stays running.

1 Like

Thank you for answering, Sir. Stay safe.