How to access a docker container on host from local VM? - docker

I have a docker container set up on the host with RabbitMQ installed and I'm trying to connect to that container and access the RMQ web UI from a Hyper-V VM. The docker container has a static ip assigned and is connected to a transparent network adapter while the VM is connected to an ethernet network adapter. I am new to networking so I have no idea how to connect the VM to the container. I've tried docker swarm but that gave me a deadline exceeded error so now I'm exploring port forwarding with the docker container or configure the VM to use bridged network mode, both of which I have no experience in. Pinging the docker container from host succeeds and so does pinging the host from VM but not the other way around. Some help would be appreciated.

Related

ip address is accessible from docker host, but not from docker container running on the host

There's some virtual machine internal network ip address which is accessible from MAC docker host. This was verified using ping.
However, the same ip address is not accessible from any docker container running on the Docker host.
I tried to run container with --network host, however the ip is still not reachable.
Then, I discovered that none of the VMs reachable from MAC docker host are reachable from any docker container running on it.
How to debug and solve this issue?
External ip addresses (of google.com ) are accessible from the container.
I performed the same test on Linux docker host. The same internal VM ip address was reachable from within the container as well as all other VMs.
It's important to note that MAC docker host is just MAC machine connecting to the network using VPN and thus getting access to internal network VMs.
Linux Docker host is VM itself in the internal network where VMs are located.
I'm using 3.6.0 MAC Docker desktop version and update regularly.

Connect to Gitlab in Docker Container in VM

On a Windows 7 host, I have a Ubuntu guest inside virtualbox which runs a gitlab docker container. Inside the VM I can connect to the Gitlab inside the browser using localhost:80. How can I make the Gitlab reachable from the host?
So far I tried a port-forwanding in virtualbox which doesn't help. In my host with ipconfig, I see three IPs. One is the hosts public IP, the other two are the VirtualBox Host-Only Networks, which I can successfully ping.

How to ping docker container from VM on the same host?

I have a docker container and a virtual machine(VM) on the same host(OpenSUSE). the docker has the IP like 172.18.0.2 and the host IP is something like 3.204.XX.XX and VM IP is also something like 3.204.xx.xx, I am able to ping the docker from the host and even the VM is pingable from the host and vice-versa but I am unable to ping the docker from the Virtual machine present on the same host. Is there a way to access the docker on the host from the VM present on the same host? please help.
it is not possible directly because docker creates its bridge "bridge0" all the traffic is been routed using nat, where as virtualbox also creates its own bridge/interface , because of which its not able to access. But you can access by exposing port.
above mention requirement is possible with consul service discovery and host n/w config modification

Spin off another container on host machine from an existing container

I am currently using Docker Desktop for Mac.
My requirement is to spin off a container from another container.
Situation:
Container A has a service running which upon request looks for a swarm manager and spin off another container B. I have started single node swarm manager on my machine. I can not use host network_mode because docker for MAC exposes light weight linux vm as host and not my actual localhost. I have tried this also : https://forums.docker.com/t/access-host-not-vm-from-inside-container/11747/7
Any possible solution?
The idea is that your container can access your host. So, use the Engine API provided by Docker:
POST /containers/create
You will have to post json that contains the details of the new container.
Engine API v1.24
The daemon listens on unix:///var/run/docker.sock but you can Bind Docker to another host/port or a Unix socket.
You can listen on port 2375 on all network interfaces with -H tcp://0.0.0.0:2375, or on a particular network interface using its IP address: -H tcp://192.168.59.103:2375. It is conventional to use port 2375 for un-encrypted, and port 2376 for encrypted communication with the daemon.

Issues with Network connectivity with Docker

I am facing issues configuring network in docker. Details are given below.
Host Machine:- Ubuntu Server 14.04 LTS 64-bit. IP subnet: 10.0.0.0/16, IP address: 10.0.0.206/16 and default gateway: 10.0.0.1/16. This machine having docker installed (version 1.6.2 build 7c8fca2) and has a default IP in the docker0 bridge of 172.17.42.1/16. However, the container has received the IP as 172.17.0.1. Problems are as follows.
My Host machine and docker container is able to connect with each other and to Internet but any other machines are not able to connect with docker container.
Changing the docker0 bridge IP is temporary and reverts back to 172.17.42.1/16 once every reboot.
I cannot set a static IP address of my container as it changes automatically at every exit or if the host is rebooted. Checked the container's network config file /etc/network/interfaces but doing changes in this file has no effect to its eth0 interface.
In very short, I am not able to connect to the container from outer world (from other physical machines) even when I have configured the networking interface of other machines to connect to docker host and container.
How can I fix this connection problem?
By default, Docker containers can not be accessed from other host. And the IP address is allocated by docker.
You can use "--net=host" when run containers, then the container will share the same IP address with the host node. And the container will be available from other node.
docker run -it --net=host ubuntu bash

Resources