mal / docker-for-mac-host-bridge

Host-accessible containers with Docker for Mac
125 stars 23 forks source link

Failed to connect to container #10

Closed bullfly66 closed 2 years ago

bullfly66 commented 6 years ago

My test result is that Failed to connect to container when i excecute curl -I container_ip I don't know what caused this

Thank you

My list of steps:

##### 1.install tuntaposx #######
╭─bullfly at npc in ~/Downloads/tuntap_20150118 using
╰─○ ls -lh /dev/tap*
crw-rw----  1 root     wheel   38,   0  8 13 11:39 /dev/tap0
crw-rw----  1 bullfly  wheel   38,   1  8 13 11:39 /dev/tap1
crw-rw----  1 root     wheel   38,  10  8 13 11:39 /dev/tap10
crw-rw----  1 root     wheel   38,  11  8 13 11:39 /dev/tap11
crw-rw----  1 root     wheel   38,  12  8 13 11:39 /dev/tap12
crw-rw----  1 root     wheel   38,  13  8 13 11:39 /dev/tap13
crw-rw----  1 root     wheel   38,  14  8 13 11:39 /dev/tap14
crw-rw----  1 root     wheel   38,  15  8 13 11:39 /dev/tap15
crw-rw----  1 root     wheel   38,   2  8 13 11:39 /dev/tap2
crw-rw----  1 root     wheel   38,   3  8 13 11:39 /dev/tap3
crw-rw----  1 root     wheel   38,   4  8 13 11:39 /dev/tap4
crw-rw----  1 root     wheel   38,   5  8 13 11:39 /dev/tap5
crw-rw----  1 root     wheel   38,   6  8 13 11:39 /dev/tap6
crw-rw----  1 root     wheel   38,   7  8 13 11:39 /dev/tap7
crw-rw----  1 root     wheel   38,   8  8 13 11:39 /dev/tap8
crw-rw----  1 root     wheel   38,   9  8 13 11:39 /dev/tap9

##### 2.DOCKER_TAP_NETWORK=acme ./install.sh tuntap_20150118.pkg ######
╭─bullfly at npc in ~/Downloads/tuntap_20150118 using
╰─○ DOCKER_TAP_NETWORK=acme ./install.sh tuntap_20150118.pkg
Install tuntap kernel extension
Password:
installer: Package name is TunTap Installer package
installer: Upgrading at base path /
installer: The upgrade was successful.
Ensure tap extension is loaded
Permit non-root usage of tap1 device
Bridge tap into docker network
Assign the network gateway IP to the tap interface
ifconfig: interface tap1 does not exist

################   3.ifconfig       ############
tap1: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
  ether 12:5d:50:4d:40:02
  media: autoselect
  status: active
  open (pid 3624)

################ 4.restart docker ############

##### 5.DOCKER_TAP_NETWORK=acme ./install.sh tuntap_20150118.pkg ######
╭─bullfly at npc in ~/Downloads/tuntap_20150118 using
╰─○ DOCKER_TAP_NETWORK=acme ./install.sh tuntap_20150118.pkg
Bridge tap into docker network
Assign the network gateway IP to the tap interface

################   6.ifconfig       ############
tap1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
  ether 12:5d:50:4d:40:02
  inet 172.19.0.1 netmask 0xffff0000 broadcast 172.19.255.255
  media: autoselect
  status: active
  open (pid 3624)

##### 7.docker container run -d --net acme --rm nginx:alpine #####
╭─bullfly at npc in ~/Downloads/tuntap_20150118 using
╰─○ docker container run -d --net acme --rm nginx:alpine
47096aee5d1df7c1afb9d8af46469693750c94013b2d3a8031d42d1448b8bd3d

##### 8. get container  ip #####
╭─bullfly at npc in ~/Downloads/tuntap_20150118 using
╰─○ docker container inspect -f '{{.NetworkSettings.Networks.acme.IPAddress}}' 47096aee5d1df7c
172.19.0.2

#### 9. docker ps #####
╭─bullfly at npc in ~/Downloads/tuntap_20150118 using
╰─○ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
47096aee5d1d        nginx:alpine        "nginx -g 'daemon of…"   3 minutes ago       Up 3 minutes        80/tcp              hopeful_jang

##### 10. test container port 80 #######
╭─bullfly at npc in ~/Downloads/tuntap_20150118 using
╰─○ curl -I 172.19.0.2
curl: (7) Failed to connect to 172.19.0.2 port 80: Operation timed out
AlvaWymer commented 5 years ago

me too

mal commented 5 years ago

Sorry for the huge delay in response, this totally fell off my radar! 😧

Interestingly I'm not seeing the log output from the install_hyperkit_shim in your example, which suggests that the installer thinks it's already installed. Only thing I can think to suggest is to attempt to uninstall the shim with the script below, and then try running install.sh again and restarting docker when it prompts to do so.

mv -v /Applications/Docker.app/Contents/MacOS/com.docker.hyperkit{.real,}
mv -v /Applications/Docker.app/Contents/Resources/bin/hyperkit{.real,}
mv -v /Applications/Docker.app/Contents/Resources/bin/com.docker.hyperkit{.real,}

As an aside, I'm afraid I'm no longer in a position to be able to debug this to any greater extent, as (partly due to this docker limitation) the dev team I built this to support has moved over completely to linux and I no longer have access to a Mac on which to test it.

mal commented 5 years ago

It's also possible that this fork by @remysaissy might be of interest as it looks like they've added a change to support newer versions of DfM which have moved the tty used to bridge the tap device into the docker network.