Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open ports are not visible on the host in host networking mode #1227

Closed
achanda opened this issue Jan 26, 2017 · 3 comments
Closed

Open ports are not visible on the host in host networking mode #1227

achanda opened this issue Jan 26, 2017 · 3 comments

Comments

@achanda
Copy link

achanda commented Jan 26, 2017

Expected behavior

I started a server on port 8000 (python -m SimpleHTTPServer) in a container in host networking mode. I expected to see that port open in the host

Actual behavior

The port was not open on the host

Information

# docker inspect temp
...
"Networks": {
                "host": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "5ce0dfea018c15da566b920c188de7702d7e7d81178094160a2bea0b2904cefc",
                    "EndpointID": "0fcc981733e92cd656fabbbe74165adeded35ff6367b55aabbec57f6e4c30752",
                    "Gateway": "",
                    "IPAddress": "",
                    "IPPrefixLen": 0,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": ""
                }
            }
...
host# nmap -sT 127.0.0.1 -p 7000-9000

Starting Nmap 7.40 ( https://nmap.org ) at 2017-01-26 16:53 GMT
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00069s latency).
Not shown: 2000 closed ports
PORT     STATE SERVICE
7396/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 18.41 seconds
container# nmap -sT 127.0.0.1 -p 7000-9000

Starting Nmap 7.40 ( https://nmap.org ) at 2017-01-26 16:54 UTC
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000096s latency).
Not shown: 2000 closed ports
PORT     STATE SERVICE
8000/tcp open  http-alt

Nmap done: 1 IP address (1 host up) scanned in 0.08 seconds

Steps to reproduce the behavior

docker run -it --net="host" alpine sh
# apk add --update nmap python
# python -m SimpleHTTPServer

After this, scan 127.0.0.1 using nmap for ports between 7000 and 9000

@samoht
Copy link
Contributor

samoht commented Jan 30, 2017

Thanks for your report!

Unfortunately --net=host is not supported on Docker for Mac, as in this case the "host" involves a Linux virtual machine and an OSX host (which do not share the same network devices). What is your use-case? If you just want to open the port 8000, you can use the usual -p option without the --net option (but I guess you have an other use-case in mind).

Implement --net=host for Docker for Desktop is a big chunk of work which is not planned in the short term.

I am closing this issue as a duplicate of #1031, feel free to monitor updates on that issue if you are interested in following progress on that issue.

@samoht samoht closed this as completed Jan 30, 2017
@niketpathak
Copy link

Any updates on this ? In 2017, host mode wasn't supported for docker for mac. Are there any evolutions as of 2020 ?

@docker-robott
Copy link
Collaborator

Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle locked

@docker docker locked and limited conversation to collaborators Jun 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants