PolarisUser
PolarisUser

Reputation: 739

Have docker not let a program bind a port to localhost

I have multiple docker containers run Jetty and Cargo. The issue is that Cargo binds a port (7868) to local host, instead of of visualizing it with docker (If I understand this correctly). If I look in one of my containers, I see that the port is bound to my localhost, and when I look at my second container, it isn't. tcp 0 0 ::ffff:127.0.0.1:7868 :::* LISTEN -

I thought that setting up a port forward, as shown in the docker doc would solve this, but apparently Cargo goes around this?

0.0.0.0:10009->7868/tcp 0.0.0.0:10010->7868/tcp

Is there a way to either have this port sent to 1000x instead of localhost, or have Docker deal with it?

edit: I realized I left out the actual issue. When both containers are running, Jetty cannot bind to the port from both containers.

Thanks

Upvotes: 0

Views: 592

Answers (1)

PolarisUser
PolarisUser

Reputation: 739

So the issue was I was not binding my port properly.

What I was doing

docker run 10010:7868 -d rhel7 /bin/bash

What I needed to do was set the IP

docker run -p 127.0.0.1:10010:7868 -d rhel7 /bin/bash

and it worked perfectly.

Upvotes: 2

Related Questions