Changing Docker ports

I have a container that is started with:

-p 127.0.0.1:40180:80 -p 127.0.0.1:48000:8000 -p 45820:5820

And I want to change it from 8000 to 9000. I changed that in the start up command, but I could not connect at 9000. Running a ps I saw:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
de63221005e3 elucidbio/capdata:v3 “/entrypoint.sh bash” 36 seconds ago Up 35 seconds 443/tcp, 8000/tcp, 127.0.0.1:40180->80/tcp, 0.0.0.0:45820->5820/tcp, 127.0.0.1:48000->9000/tcp mad_swirles

Then I noticed in the Dockerfile this:

EXPOSE 8000 80 443

So I changed that 8000 to 9000 and rebuilt the container. Now when I run I still cannot connect to 9000, and a ps shows this:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
be92aad6bd0c elucidbio/capdata-bach:v3 “/entrypoint.sh bash” 8 seconds ago Up 7 seconds 443/tcp, 127.0.0.1:40180->80/tcp, 0.0.0.0:45820->5820/tcp, 127.0.0.1:48000->9000/tcp hungry_dijkstra

I don’t see port 9000 as being exposed.

What am I missing here to change the port?

So: you have a server running inside the container that is listening on 0.0.0.0:80, 0.0.0.0:5820, and you originally thought 0.0.0.0:8000, but actually 0.0.0.0:9000? And you want to expose those ports, to the local system only, to ports 48010, 45820, and 48000, respectively?

Everything you show suggests the Docker side of this is working correctly, and if I was going to guess at something, I’d guess you also need to change something in how you’re configuring or running the program inside the container to listen on port 9000 instead of 8000.

(That’s a slightly odd, change, though, in that because Docker remaps the ports, it doesn’t really matter much which port(s) the program inside the container is listening on…do you actually want to change the external port number 48000, without modifying what’s going on inside the container?)

From outside the container you’d be connecting to localhost:48000.

I’m somewhat new at this, and it is an existing app that someone who no longer works here wrote, and it was dropped in my lap to support. I am confused about all the port mapping that goes on. In the nginx config there are services defined at 8000 and 8001. 8000 maps to a service not in docker, and 8001 is mapped to 48000, which is the server in the docker container. The external apps connect to both 8000 and 8001, and I want to change that to 9000 and 9001. I did change the nginx config to 9000 and 9001. And now I am thinking I do not need to change the docker ports at all. But what is very confusing to me is the docker mapping of 48000 to 8000 inside the container, when outside the continuer 8000 maps to something not in docker at all, and 8001 maps to 48000.

So am I correct that to change the external port to 9001 I do not have change any docker ports?

Also confused by the EXPOSE 8000 80 443 in the Dockerfile, and why in the ps I saw 8000/tcp before, and why now, when I am running the same image as before (I just switched back) I don’t see that in the ps.