Can't set host port. Works only :5000 port

Hello Everybody!
I am facing with issue with port setting

I run the command with 8067 port( or any other port):

docker run -d -p 8067:8067 identidock

in “Logs” of container I see:

** Running on (Press CTRL+C to quit)**
** Restarting with stat**
** Debugger is active!**
** Debugger PIN: 337-801-390**

And I can’t access to localhost:8067 or localhost:5000

but when I run a commands like these:

identidock % docker run -d -p 504:5000 identidock
identidock % docker run -d -p 5000:5000 identidock
identidock % docker run -d -p 4242:5000 identidock

then everything are ok and http://localhost:5000 works…

It means that problem with host port but I can’t figure out how to solve this problem.
I will appreciate if you can help me.

P.S.: AirPlay receiver turned off.
P.S.S.: Environment:
MacOS: 13.0
Apple M1

docker version
Cloud integration: v1.0.29
Version: 20.10.20
API version: 1.41
Go version: go1.18.7
Git commit: 9fdeb9c
Built: Tue Oct 18 18:20:35 2022
OS/Arch: darwin/arm64
Context: desktop-linux
Experimental: true

Server: Docker Desktop 4.13.1 (90346)
Version: 20.10.20
API version: 1.41 (minimum version 1.12)
Go version: go1.18.7
Git commit: 03df974
Built: Tue Oct 18 18:18:16 2022
OS/Arch: linux/arm64
Experimental: false
Version: 1.6.8
GitCommit: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
Version: 1.1.4
GitCommit: v1.1.4-0-g5fd4c4d
Version: 0.19.0
GitCommit: de40ad0

You just forwarded the host port 8067 to the container port 8067. It will not change the port that the service in the container is listening on. Change only the host port and leave the container port as 5000.

docker run -d -p 8067:5000 identidock

What problem? I think it works as expected.

And please, use code blocks instead of quotes next time so codes, terminal outputs and log messages will be more readable:

1 Like
docker run -d -p 3595:6787 identidock
 * Running on (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 337-801-390

the problem is that when I set any host port other than 5000, I can’t open the page.

How can I run different containers with different host ports if I can’t change host ports?

sorry, I’ll fix it in the next posts

You changed the container port again. Why? The service is listening on port 5000 and it will not listen on other ports unless you change the configuration of the application. Docker will not do that for you, it can’t, and you don’t even need that. You know on which port a service is listening in the container and you can forward a host port (any available) to that container port. So why do you expect the port to work, if the app uses port 5000 and you forward the host port to port 6768?

The only thing you should change is the host port (on the left side) and you don’t need to change the container port.

1 Like

Thanks a lot! Now all clear!