0

first of all, I'm a totally n00b in docker, but I got into a project that are actually running in docker, so I've been reading about it.

My problem is, I have to inspect my development environment in a mobile device(iOS). I tried to access by my docker ip because this is what I basically do in my computer. After a few failed attempts I noticed that I've to access with the docker network bridge instead of docker host(the default).

I already have defined my docker bridge( I think its default), but i have no idea how to run my server with this network, can you guys help me?

A few important notes:

  • I'm using MAC OS X El capitan ( 10.11.1 )
  • The device and the mac are in the same wi-fi network and i can access using regularly localhost outside docker.
  • My following steps to run my server is:

    1. cd gsat_grupo_5/docker && docker-compose -p gsat_grupo_5 up -d
    2. docker exec -it gsatgrupo5_web_1 bash
    3. python manage.py runserver 0.0.0.0:8000
  • When I run docker ps my output is:

enter image description here

My docker bridge output:

    {
        "Name": "bridge",
        "Id": "1b3ddfda071096b16b92eb82590326fff211815e56344a5127cb0601ab4c1dc8",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.17.0.0/16",
                    "Gateway": "172.17.0.1"
                }
            ]
        },
        "Internal": false,
        "Containers": {
            "565caba7a4397a55471bc6025d38851b1e55ef1618ca7229fcb8f8dfcad68246": {
                "Name": "gsatgrupo5_mongo_1",
                "EndpointID": "471bcecbef0291d42dc2d7903f64cba6701f81e003165b6a7a17930a17164bd6",
                "MacAddress": "02:42:ac:11:00:05",
                "IPv4Address": "172.17.0.5/16",
                "IPv6Address": ""
            },
            "5e4ce98bb19313272aabd6f56e8253592518d6d5c371d270d2c6331003f6c541": {
                "Name": "gsatgrupo5_thumbor_1",
                "EndpointID": "67f37d27e86f4a53b05da95225084bf5146261304016809c99c7965fc2414068",
                "MacAddress": "02:42:ac:11:00:03",
                "IPv4Address": "172.17.0.3/16",
                "IPv6Address": ""
            },
            "a0b62a2da367e720d3a55deb7377e517015b06ebf09d153c6355b8ff30cc9977": {
                "Name": "gsatgrupo5_web_1",
                "EndpointID": "52687cc252ba36825d9e6d8316d878a9aa8b198ba2603b8f1f5d6ebcb1368dad",
                "MacAddress": "02:42:ac:11:00:06",
                "IPv4Address": "172.17.0.6/16",
                "IPv6Address": ""
            },
            "b3286bbbe9259648f15e363c8968b64473ec0a9dfe1b1a450571639b8fa0ef6f": {
                "Name": "gsatgrupo5_mysql_1",
                "EndpointID": "53290cb44cf5ed8322801d2dd0c529518f7d414b3c5d71cb6cca527767dd21bd",
                "MacAddress": "02:42:ac:11:00:04",
                "IPv4Address": "172.17.0.4/16",
                "IPv6Address": ""
            }
        },
        "Options": {
            "com.docker.network.bridge.default_bridge": "true",
            "com.docker.network.bridge.enable_icc": "true",
            "com.docker.network.bridge.enable_ip_masquerade": "true",
            "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
            "com.docker.network.bridge.name": "docker0",
            "com.docker.network.driver.mtu": "1500"
        },
        "Labels": {}
    }
]

If there's some another smart approach to access my environment in my mobile device I'm listening.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Yuri Pereira
  • 1,945
  • 17
  • 24

1 Answers1

0

I've to access with the docker network bridge instead of docker host(the default).

Unless you have a protocol that does something odd, like connecting back out to the device from the server, normally accessing <macip>:8000 from your device would be enough. Can you test the service from any other computers?

If you do require direct access the container network, that's a bit harder when using a Mac...

Docker for Mac doesn't support direct access to the Linux virtual machines bridge networks where your containers run.

Docker Toolbox runs a VirtualBox VM with the boot2docker vm image. It would be possible to use this but it's a little harder to apply custom network config to the VM that is setup and run via the docker-machine tools.

Plain Virtualbox is probably your best option, running your own VM with Docker installed.

Add two bridged network interfaces to the VM in Virtualbox. One for the VM and one for the the container, so they can both be available on your main network.

The first interface is for the host. It should pick up an address from DHCP like normal and Docker will then be available on your normal network.

The second bridged interface can be attached to your docker bridge and then the containers on that bridge will be on your home network.

On pre v1.10 versions of docker Pipework can be used to physically mapped an interface in to the container.

There is some specific VirtualBox interface setup required for both methods to make sure all this works.

Vagrant

Vagrant might make the VM setup a bit easier and repeatable.

$ mkdir dockervm
$ cd dockervm
$ vagrant init debian/jessie64

Vagrantfile network config:

config.vm.network "public_network", bridge: "en1: Wi-Fi (AirPort)"
config.vm.network "public_network", bridge: "en1: Wi-Fi (AirPort)"

config.vm.provider "virtualbox" do |v|
  v.customize ['modifyvm', :id, '--nictype1', 'Am79C973']
  v.customize ['modifyvm', :id, '--nicpromisc1', 'allow-all']
  v.customize ['modifyvm', :id, '--nictype2', 'Am79C973']
  v.customize ['modifyvm', :id, '--nicpromisc2', 'allow-all']
end

Note that this VM will have 3 interfaces. The first interface is for Vagrant to use as a management address and should be left as is.

Start up

$ vagrant up
$ vagrant ssh 
Community
  • 1
  • 1
Matt
  • 68,711
  • 7
  • 155
  • 158