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

How to get true net=host? #271

Closed
alininja opened this issue Aug 14, 2016 · 3 comments
Closed

How to get true net=host? #271

alininja opened this issue Aug 14, 2016 · 3 comments

Comments

@alininja
Copy link

Hi, sorry if this isn't really a bug.

Expected behavior

I wanted to have the container use the same IP as the Mac host using the --net=host or network_mode: host options.

Actual behavior

The HyperKit/xhyve/bhyve or something requires the container to take on a separate IP.

Information

Diagnostic ID: FF15D52E-9115-4F19-8A44-C88B257007C2
Docker for Mac: 1.12.0-a (Build 11213)
macOS: Version 10.11.6 (Build 15G31)
[OK] docker-cli
[OK] app
[OK] moby-syslog
[OK] disk
[OK] virtualization
[OK] system
[OK] menubar
[OK] osxfs
[OK] db
[OK] slirp
[OK] moby-console
[OK] logs
[OK] vmnetd
[OK] env
[OK] moby
[OK] driver.amd64-linux

Steps to reproduce

  1. ifconfig | grep inet #192.168.xxx.xxx
  2. docker run --net=host --rm -i cyberkov/node-sonos-http-api /bin/sh
  3. ifconfig | grep inet #192.168.yyy.yyy

The reason I want the container IP to match the host IP is because the container is trying to discover uPNP devices so the devices need to be able to reach back to the container directly.

Maybe there's some other Docker/networking/uPNP trick that I'm missing. But if there is, then please let me know.

I'm also not sure if the docs should make users aware that --net=host for Docker for Mac behaves slightly different. 20/20 hindsight says it should have occurred to me that there is another machine inside the host, but everything works so transparently with Docker for Mac, it just totally didn't occur to me until hours later.

Thanks again for such an awesome product.

@bric3
Copy link

bric3 commented Oct 11, 2016

Another use case, I'd like to use binaries in docker images, e.g. cqlsh or sqlplus to access connect an ssh tunnel opened on my host to access distant machines right now this doesn't seem to work.

± ❯ ssh -Nf stg-cassandra2
± ❯ telnet localhost 19042
Trying ::1...
Connected to localhost.
Escape character is '^]'.
^]
telnet> quit
Connection closed.
± ❯ docker run -it --net=host --rm alpine telnet localhost 19042
telnet: can't connect to remote host (127.0.0.1): Connection refused

On linux it works.

Just in case the ssh config is ok

Host stg-cassandra2
   HostName 10.x.x.x
   LocalForward 19042 10.x.x.x:9042

Diagnose

Docker for Mac: version: 1.12.2-rc1-beta27 (179c18c)
OS X: version 10.11.6 (build: 15G1004)
logs: /tmp/169BF977-A7DB-43D5-878B-C3A3A6785689/20161011-182006.tar.gz
[OK]     docker-cli
[OK]     virtualization kern.hv_support
[OK]     menubar
[OK]     moby-syslog
[OK]     dns
[OK]     disk
[OK]     system
[OK]     app
[OK]     osxfs
[OK]     virtualization VT-X
[OK]     db
[OK]     slirp
[OK]     logs
[OK]     env
[OK]     vmnetd
[OK]     moby-console
[OK]     moby
[OK]     driver.amd64-linux

@samoht
Copy link
Contributor

samoht commented Jan 31, 2017

I am consolidating the issue of make --net=host into #1031, so please subscribe to updates there to be kept updated on the progress we make on that feature. Thanks!

@samoht samoht closed this as completed Jan 31, 2017
@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 18, 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

7 participants