Home > Back-end >  Use Docker with same port as other program
Use Docker with same port as other program

Time:05-07

I am currently facing following problem: I build a docker container of a node server (a simple express server which sends tracing data to Zipkin on port 9411) and want to run it along Zipkin. So as I understood, the node server should send tracing data to Zipkin using port 9411. If I run the server with node only (not as docker), I can run it along Zipkin and everything is working fine. But if I got Zipkin running and than want to fire up my Docker Container, I get the error

Error starting userland proxy: listen tcp4 0.0.0.0:9411: bind: address already in use.

My understanding is that there is a conflict concerning the port 9411, since it seems to be blocked by Zipkin, but obviously, also the server in the Docker container needs to use it to communicate with Zipkin.

I would appreciate if anybody got an idea how I could solve this problem.

Greetings, Robert

CodePudding user response:

When you start a docker container, you add a port binding like this:

docker run ... -p 8000:9000

where 8000 is the port you can use on the pc to access port 9000 within the container.

Don't bind the express server to 9411 as zipkin is already using that port.

CodePudding user response:

I found the solution: using the flag --network="host" does the job, -p also is not needed.

  • Related