Not sure if it's a machine or docker configuration problem.
I have a VM with public IP (176.X.XXX.XXX) and private IP (10.X.XXX.XXX) and I'd like other VMs to access my container through private IP as they are in the same network.
So I do
ports:
- "10.X.XXX.XXX:9200:9200"
but this exposes the port to 176.X.XXX.XXX as well, which is not desired.
and when I expose it to localhost only
ports:
- "127.0.0.1:9200:9200"
I can't access it from other VMs on the private network.
This is most probably because of either
This is an aws/gcp/azure/droplet/etc instance in which case the cloud provider NATs the public IP address to the private IP address
You have managed to NAT the public IP address to private IP address explicitly for some reason
Related
I have created a sonarqube docker container in Azure Linux however, I am unable to access it. The Azure Linux VM doesn't have a public IP. It only has a Private IP address.
Anyways, can I access the container on Private IP?
# docker run -d --name sonarqube -p 1.1.1.1:9000:9000 sonarqube:lts
25c34ffb9775a4bd7761d1de1583d4d187f6ce9be6e5db3a419afd1f05806523
HSTSCMN20356:/opt/sonarqube/elasticsearch/config # docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
25c34ffb9775 sonarqube:lts "./bin/run.sh" 6 seconds ago Up 4 seconds 1.1.1.1:9000->9000/tcp sonarqube
:/opt/sonarqube/elasticsearch/config #
You can access the container on the private address from any machine within the network (like another VM on the same network). You need to have a public IP address to access it over the internet from your PC or you need to connect your PC to the private network using a VPN.
Make sure that sonarqube is not bound to loopback IP (127.x.x.x).
PS: 1.1.1.1 doesn't seem to be a correct internal IP. Are you sure that's your internal IP address?
Currently, I'm trying to create a docker swarm network over hosts. We have two different network sites, and one is a closed and private network. In this closed site, there is only one public IP assigned to us and hosts in this site have private IP addresses. Hosts in another network site have own public IP address to each host so there is no problem.
What I want to do is connecting hosts in the closed network site (called internal hosts) and hosts that have their own public IP addresses (called external hosts).
Because the only one public IP assigned to us for the closed network site, I set this public IP designated one internal host in the closed network site and this host became the docker swarm manager. Then, internal hosts joined to the swarm network using the internal IP address of the swarm manager host and external hosts joined using the public IP address.
For example, in the internal hosts:
docker swarm join --token ... 172.0.12.12:2377
and in the external hosts:
docker swarm join --token ... 123.123.123.123:2377
Joining was successfully done and I could recognize all nodes correctly in the swarm manager using docker node ls command. However, when I create an overlay network, this network is recognized in external hosts, but not in internal hosts. So, when I created a container in an external host and tried to ping from an internal host, it failed.
Is this a wrong way? Or is there anything that I should check? Any kind of ideas will be very helpful. Thanks!
I would like to deploy multiple applications via docker. Some of them are using the same port.
An alternative port mapping (Port 80->5080) is not an option, so my way to handle the problem is a network bridge which should allow me to assign an ip address from my internal network to each container.
The answer from this post does not work for me
Assign LAN IP address to Docker container different from host's IP address
i am able to assign an ip to the docker container, but it also gets the host ip address so i can not map ports.
Is it possible to assign a static IP address and hostname to a docker container after it's creation ?
All my container are in the same network (bridge). The docker IP 172.17.0.x assigned by bridge network to my containers change some time after a restart of docker service and I need a static IP to save the communication between container.
Another idea is to associate hostname to container. IP address is not static.
Here a simple way to use docker network to add hostname to existing container.
[link] https://stackoverflow.com/a/41298050/6288254
Is there theoretically anyway to connect nodes to a Docker swarm if they are on a private network and don't have a public IP? The swarm host has a public IP, and the nodes can access it as well as a discovery service just fine, but they themselves are on private networks over which I have no control. So is this possible?
I this situation you ether tunnel the requests or use weave for creating the Virtual Private network.