9

What I am unable to do:

Can ping the default docker network's gateway ip from the Ubuntu container, but cannot ping the container from the host machine, I have tried looking at here but this is something the other way round. I want to access my container from my host machine.

What I have tried

So I created a custom network using this:

docker network create --driver=bridge --subnet=192.168.0.1/24 --ip-range=192.168.0.130/24 --gateway=192.168.0.1 br0

This is the newly added network

$ docker network ls
NETWORK ID          NAME                DRIVER
38bcca85e37a        bridge              bridge
202ace7d3e0c        none                null
512b3a6dc77f        host                host
d5f4b00e3281        br0                 bridge

and verified through the inspect command:

$ docker network inspect br0
[
    {
        "Name": "br0",
        "Id": "d5f4b00e3281c27e6d5879ac37463b6d8af728944dc7d3fbc23c25092020c7c7",
        "Scope": "local",
        "Driver": "bridge",
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "192.168.0.1/24",
                    "IPRange": "192.168.0.130/24",
                    "Gateway": "192.168.0.1"
                }
            ]
        },
        "Containers": {},
        "Options": {}
    }
]

and then ran my container using the following command:

docker run  -i -d --name=rc  --net br0 --ip 192.168.0.150 -v /var/log/restcomm/:/var/log/restcomm/ -e STATIC_ADDRESS="192.168.0.150" -e ENVCONFURL="https://raw.githubusercontent.com/RestComm/Restcomm-Docker/master/scripts/restcomm_env_locally.sh" -p 80:80 -p 443:443 -p 9990:9990 -p 5060:5060 -p 5061:5061 -p 5062:5062 -p 5063:5063 -p 5060:5060/udp -p 65000-65050:65000-65050/udp restcomm/restcomm:latest

then I logged on to the running container and ran the ifconfig command

$ docker exec -it a09a4c120999 bash
 root@8412c266634d:/# ifconfig
eth0      Link encap:Ethernet  HWaddr 02:42:c0:a8:00:96
          inet addr:192.168.0.150  Bcast:0.0.0.0  Mask:255.255.255.0
          inet6 addr: fe80::42:c0ff:fea8:96/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:508 (508.0 B)  TX bytes:508 (508.0 B)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:142 (142.0 B)  TX bytes:142 (142.0 B)



root@a09a4c120999:/# exit

The problem here is still that even the IP of this container is set to be 192.168.0.150 but it is still unable to ping the host machine whose IP is 192.168.0.115. Also the above command I have to run quickly, as you can see the container exits by itself, so i restart the container again and again to try and run a single command, if I try to login in again without restarting, it gives the following error:

$ docker exec -it e0783d69b96f bash
Error response from daemon: Container e0783d69b96f8e7ff4a17f76d0066b78c4b54a6817de7526a514f42a6af4640e is not running: Exited (1) 1 seconds ago

I verified this also by listing all the containers

$ docker ps -a
CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS                         PORTS               NAMES
e0783d69b96f        restcomm/restcomm:latest   "/sbin/my_init"          5 minutes ago       Exited (1) 4 minutes ago                           rc

I am running docker on windows 10 and followed these instructions from here

Edit: The container exits itself after I add this custom network, so probably there is something wrong in trying to add the network, but this command i have found in their official tutorial from here

So there are 2 problems

  1. Even though I can specify the IP I want I am still unable to ping to and from the container and host
  2. The container exists itself after I add the custom network

EDIT:

Thanks to @VonC I fixed the second problem by adding the recommended switch, yes these two are not related

Community
  • 1
  • 1
shabby
  • 3,002
  • 3
  • 39
  • 59
  • 1
    Problem 1 is certainly not helped by problem 2... To test your network, simply use `docker run -itd --name rc --net br0 busybox`. That won't exit. – VonC Mar 11 '16 at 13:06
  • oh yeah great now its not exiting, but I still cant ping to and from container and host, now the container IP is 192.168.0.2 and my host IP is 192.168.0.115 – shabby Mar 11 '16 at 13:24
  • 1
    I never tried to ping a container from the actual host (Windows). I only pinged the Linux host (the boot2docker VM). And made sure my port were mapped on docker run to port in the Linux host. – VonC Mar 11 '16 at 13:27
  • My guess: The Windows host is not aware that there is a subnet that is reachable via the Linux VM. On Linux, I would try to run `route` to see the routing. According to [this post](http://superuser.com/questions/346347/on-windows-how-to-determine-route-for-ip-destination), `tracert 192.168.0.115` is the equivalent command for Windows. – morxa Mar 11 '16 at 17:27
  • @morxa your guess is very much correct, but what is the process of making the windows host aware of the subnet so that I can access the container from the host – shabby Mar 12 '16 at 15:33
  • did you tried to check VLANS? – ALUFTW Nov 29 '16 at 13:18

0 Answers0