It's possible to changed NetworkSettings HostIp from 127.0.0.1 to 0.0.0.0?

Hello team,
Currently I face issue with connection was set NetworkSettings HostIp from 127.0.0.1 that I can’t access any Tools to DB , and i want to changed hostip to 0.0.0.0 ? so my question it’s possible to changed NetworkSettings HostIp from 127.0.0.1 to 0.0.0.0?

Please let us know, how this is related to docker. Furthermore, please extend on why you think it makes sense to change the host ip to 0.0.0.0, which is a place holder for all ip’s on the host.

Since you didn’t really describe what your issue was and what you mean by NetworkSettings or HostIp, without context, I will have a big guess and say this. docker inspect can show a json in which NetworkSettings is key. For example:

        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "37f042f9065ff9a3f9d6670eabebd6801d050d5d8e5845ea9568ee28288171ff",
            "SandboxKey": "/var/run/docker/netns/37f042f9065f",
            "Ports": {
                "80/tcp": [
                    {
                        "HostIp": "127.0.0.1",
                        "HostPort": "8888"
                    }
                ]
            },

It also shows HostIp which is the IP from which you forwarded a port. If you could forward the port, you could try to change your command to use the 0.0.0.0 placeholder which is indeed something that can be used in the forward rule and when you don’t define the IP address, it is the default. Since you could have tried it without asking the question, my second bug guess is that you didn’t want to run a new container after removing the previous one, but you want to change the source IP (host ip) in a running container. No that is not possible. I mean if you go deep enough, everything is possible, but shouldn’t be done and the right way is removing the recrating the container with the new host IP. Or run a proxy on the host that listens on the all available IP addresses and forward it to the loopback IP address.

to change the Ip address, go to configuration file, then modify the host Ip to 0.0.0.0. and other necessary setting. After saving the file, make sure to restart the service to make the new changes apply.

Which configuration file? did you understand something that we couldn’t?

Which service? You couldn’t even change the ip without recreating the container which is more than restarting, so what is that you know and we don’t? :slight_smile:

1 Like

Hi Meyay,
currently i face issue i can’t access DB tool outside to connect into docker with information : 127.0.0.1:3306->3306/tcp , while other uat server it’s working fine with IP: 0.0.0.0. that why i asking for help it’s possible to changed IP on exiting container or not as i am just start to learn docker only.

Below is information
61f3ca16b291 traefik:v2.3 “/entrypoint.sh --ap…” 3 years ago Up 19 hours 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:8080->8080/tcp, 127.0.0.1:3306->3306/tcp traefik_reverse-proxy_1

Thank you,
Chomnan

HI rimeke,

Thank for your helping pls see below describe :

currently i face issue i can’t access DB tool outside to connect into docker with information : 127.0.0.1:3306->3306/tcp , while other uat server it’s working fine with IP: 0.0.0.0. that why i asking for help it’s possible to changed IP on exiting container or not as i am just start to learn docker only.

below is other information:

61f3ca16b291 traefik:v2.3 “/entrypoint.sh --ap…” 3 years ago Up 19 hours 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:8080->8080/tcp, 127.0.0.1:3306->3306/tcp traefik_reverse-proxy_1

“NetworkSettings”: {
“Bridge”: “”,
“SandboxID”: “fef09ac0b24e9f36ffcc9a50cb28f686264ddce8588792d2e437ad97764ebbd1”,
“HairpinMode”: false,
“LinkLocalIPv6Address”: “”,
“LinkLocalIPv6PrefixLen”: 0,
“Ports”: {
“3306/tcp”: [
{
“HostIp”: “127.0.0.1”,
“HostPort”: “3306”
}
],

Thank you,
Chomnan

Hi brother rimelek,

it’s correct way to to that right? if yeah could you guide me to do it? as i am basic docker learning …

Thank you,
Chomnan

Does “DB tool outside” mean on the same host?

  • Then accessing it with 127.0.0.1:3306 should work.
  • If it means its on another host, then you will need to delete the container and re-create it, but this time without specifying an ip in the port mapping. Using 0.0.0.0 instead of not declaring a host ip has the same effect, as it’s the default value anyway.

Yeah, meyay DB Tool was outside source, and I also try connection with IP: 127.0.0.1:3306 it’s not work. any other alternation way to delete the container and re-create as i don’t want to impact on exiting container , and also i am basic docker user too.

127.0.0.1:3306 works on the Docker host and the container itself, but from nowhere else. There is a reason why the name for this ip is localhost.

Containers are disposable by design. It is a common practice to delete containers and replace them with additional parameters (like a new version of the image). As long as you declared all volumes required to persist application data outside the container, a new container that uses the same volume will continue to use the same data.

You can copy files from an existing container:

1 Like