Reputation: 69
I have a docker compose file creaeting multiple containers. It looks that docker ports are only bound to 127.0.0.1, but not to 0.0.0.0
This is an extract of the docker compose file, quite simple:
database:
image: mariadb:11.2
container_name: ua-database
environment:
- MARIADB_ROOT_USER=root
- MARIADB_ROOT_PASSWORD=1231231
- MYSQL_TCP_PORT= 3308
ports:
- "3308:3308"
restart: unless-stopped
I have the same issue if I test test with "0.0.0.0:3308:3308" or with my IP "192.168.10.153:3308:3308" (in this case, localhost do not works any more, normal).
It was working perfectly, but stop working 2 days ago without any change. The same configuration work very well on the other developer host.
I can access to the database with 127.0.0.1, but not with my IP.
what I get with docker ps -a (port looks to be binded to 0.0.0.0)
I cannot connect with my IP (I use curl just to test the connection to mysql):
It's 2 days I'm searching, but not I'm stuck, of course 2 days before the release....
Any clue? Thanks.
Upvotes: 0
Views: 597
Reputation: 1
Containers use the same DNS servers as the host by default. DNS = 127.0.0.1 refers to the container's own loopback address. The IP address 127.0.0.1, also called loopback, is exclusively for localhost use. So, in your case it worked. Now, if you have virtualization installed in your machine then you could have used 0.0.0.0 as IP. It is basically the "no particular address" placeholder. If you are using it to configure an interface, it can remove an address from the interface, instead. Now, in the context of servers, 0.0.0.0 means "all IPv4 addresses on the local machine". If a host has ip addresses, 127.0.0.1 and a server running on the host listens on 0.0.0.0, it will be reachable at this IPs. Hope, its helps.
Upvotes: 0