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

No docker0 on docker for mac? #22753

Open
NinoFloris opened this Issue May 15, 2016 · 110 comments

Comments

Projects
None yet
@NinoFloris

NinoFloris commented May 15, 2016

Output of docker version:

Client:
 Version:      1.11.1
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   5604cbe
 Built:        Wed Apr 27 00:34:20 2016
 OS/Arch:      darwin/amd64

Server:
 Version:      1.11.1
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   8b63c77
 Built:        Tue May 10 10:39:20 2016
 OS/Arch:      linux/amd64

Output of docker info:

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 21
Server Version: 1.11.1
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 25
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: null host bridge
Kernel Version: 4.4.9-moby
Operating System: Alpine Linux v3.3
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 1.954 GiB
Name: moby
ID: DFWG:ZZBI:QGZP:CAFF:PZVX:WLED:3XNK:J2LK:UV3V:X2JR:VCGJ:QFBK
Docker Root Dir: /var/lib/docker
Debug mode (client): false
Debug mode (server): true
 File Descriptors: 17
 Goroutines: 38
 System Time: 2016-05-15T23:53:58.530098977Z
 EventsListeners: 1
Registry: https://index.docker.io/v1/

Additional environment details (AWS, VirtualBox, physical, etc.):

Steps to reproduce the issue:
1.
2.
3.

Describe the results you received:
No docker0 and absolutely no way to connect to services running on docker host via bridge gateway.
I have tried it all and thought I was going crazy, then I tried exactly the same things on my ubuntu host with zero problems

Describe the results you expected:
I would like to be able to connect to my local redis and other services without having to dockerize these...

@HackToday

This comment has been minimized.

Show comment
Hide comment
@HackToday

HackToday May 16, 2016

Contributor

did you find ip in virtualbox or on host ?

I think the docker0 was on the virtualbox VM.

Contributor

HackToday commented May 16, 2016

did you find ip in virtualbox or on host ?

I think the docker0 was on the virtualbox VM.

@NinoFloris

This comment has been minimized.

Show comment
Hide comment
@NinoFloris

NinoFloris May 16, 2016

Im talking about docker for mac that is in beta and does not do its work via a vm

NinoFloris commented May 16, 2016

Im talking about docker for mac that is in beta and does not do its work via a vm

@MiteshSharma

This comment has been minimized.

Show comment
Hide comment
@MiteshSharma

MiteshSharma May 16, 2016

I am also facing exact same issue. Found ip address of host on docker machine using below command. Assuming 0.0.0.0 represent host, correct me if i am wrong here.
netstat -nr | grep '^0.0.0.0' | awk '{print $2}'
172.17.0.1

but when do curl on this ip with a port where i am running a web server it gives connection refused.
curl 172.17.0.1:9000
curl: (7) Failed to connect to 172.17.0.1 port 9000: Connection refused

Not sure how to get proper fix. This seems to be giving trouble as need to connect to service which will run on host machine.
Also found a way to fix ip address of host machine by setting it in DOCKER_OPTS.
DOCKER_OPTS="-H tcp://0.0.0.0:5000 -H unix:///var/run/docker.sock --bip=172.17.42.1/16"

but where on mac can i put this options? on ubuntu it can be placed at /etc/default/docker.

Please provide directions if this can be fixed on mac.

MiteshSharma commented May 16, 2016

I am also facing exact same issue. Found ip address of host on docker machine using below command. Assuming 0.0.0.0 represent host, correct me if i am wrong here.
netstat -nr | grep '^0.0.0.0' | awk '{print $2}'
172.17.0.1

but when do curl on this ip with a port where i am running a web server it gives connection refused.
curl 172.17.0.1:9000
curl: (7) Failed to connect to 172.17.0.1 port 9000: Connection refused

Not sure how to get proper fix. This seems to be giving trouble as need to connect to service which will run on host machine.
Also found a way to fix ip address of host machine by setting it in DOCKER_OPTS.
DOCKER_OPTS="-H tcp://0.0.0.0:5000 -H unix:///var/run/docker.sock --bip=172.17.42.1/16"

but where on mac can i put this options? on ubuntu it can be placed at /etc/default/docker.

Please provide directions if this can be fixed on mac.

@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah May 16, 2016

Member

ping @justincormack perhaps you have some hints here.

Member

thaJeztah commented May 16, 2016

ping @justincormack perhaps you have some hints here.

@NinoFloris

This comment has been minimized.

Show comment
Hide comment
@NinoFloris

NinoFloris May 16, 2016

@MiteshSharma exactly, that is one of the first things I tried as well and with exactly the same problems

NinoFloris commented May 16, 2016

@MiteshSharma exactly, that is one of the first things I tried as well and with exactly the same problems

@MiteshSharma

This comment has been minimized.

Show comment
Hide comment
@MiteshSharma

MiteshSharma May 16, 2016

@NinoFloris Seems like we both are exact same place. In my case i am running mysql on my host machine.
Hey guys,
Do update if someone is able to do this.

MiteshSharma commented May 16, 2016

@NinoFloris Seems like we both are exact same place. In my case i am running mysql on my host machine.
Hey guys,
Do update if someone is able to do this.

@HackToday

This comment has been minimized.

Show comment
Hide comment
@HackToday

HackToday May 16, 2016

Contributor

I used this
https://docs.docker.com/engine/installation/mac/

not sure if your beta any special

Contributor

HackToday commented May 16, 2016

I used this
https://docs.docker.com/engine/installation/mac/

not sure if your beta any special

@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah May 16, 2016

Member

@HackToday that's different, that's the VirtualBox based Mac installation; Docker for Mac is on beta.docker.com

Member

thaJeztah commented May 16, 2016

@HackToday that's different, that's the VirtualBox based Mac installation; Docker for Mac is on beta.docker.com

@HackToday

This comment has been minimized.

Show comment
Hide comment
@HackToday

HackToday May 17, 2016

Contributor

Thanks @thaJeztah Any possible good doc link for related Mac Docker architecture or something else details? Seems interesting

Contributor

HackToday commented May 17, 2016

Thanks @thaJeztah Any possible good doc link for related Mac Docker architecture or something else details? Seems interesting

@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah May 17, 2016

Member

@HackToday https://blog.docker.com/2016/03/docker-for-mac-windows-beta/ gives a little more, and there is documentation, but I think it's only if you are in the beta; https://beta.docker.com/docs/. If you sign-up for the beta, then give me a "ping"; I can try to get you on the priority list as a contributor 😄

Member

thaJeztah commented May 17, 2016

@HackToday https://blog.docker.com/2016/03/docker-for-mac-windows-beta/ gives a little more, and there is documentation, but I think it's only if you are in the beta; https://beta.docker.com/docs/. If you sign-up for the beta, then give me a "ping"; I can try to get you on the priority list as a contributor 😄

@HackToday

This comment has been minimized.

Show comment
Hide comment
@HackToday

HackToday May 17, 2016

Contributor

oh @thaJeztah Thanks, I thought it was a free to work and try. Not need any special to contribute. I will read that blog first to understand before I try. 😺

Contributor

HackToday commented May 17, 2016

oh @thaJeztah Thanks, I thought it was a free to work and try. Not need any special to contribute. I will read that blog first to understand before I try. 😺

@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah May 17, 2016

Member

@HackToday it's completely free, just to not overwhelm the team, it was decided to release it as a "private" beta first, because "many users' === "many support questions" 😄

Member

thaJeztah commented May 17, 2016

@HackToday it's completely free, just to not overwhelm the team, it was decided to release it as a "private" beta first, because "many users' === "many support questions" 😄

@justincormack

This comment has been minimized.

Show comment
Hide comment
@justincormack

justincormack May 17, 2016

Contributor

Hi, yes there is not currently a way to route from the Mac to the docker0 bridge. We may be able to add this later, but generally we would recommend you connect from a container, or by exposing ports. This is the same as with docker overlay networks as well on Linux, which you cannot connect to from the host.

Contributor

justincormack commented May 17, 2016

Hi, yes there is not currently a way to route from the Mac to the docker0 bridge. We may be able to add this later, but generally we would recommend you connect from a container, or by exposing ports. This is the same as with docker overlay networks as well on Linux, which you cannot connect to from the host.

@NinoFloris

This comment has been minimized.

Show comment
Hide comment
@NinoFloris

NinoFloris May 17, 2016

Well not really satisfactory as macs are usually not production servers but
dev machines.

On my production machines i dont mind the problem of not being able to
connect to the host.

But on a dev machine connecting to services on the same host from inside a
container is exactly the scenario where this functionality is desired the
most.

NinoFloris commented May 17, 2016

Well not really satisfactory as macs are usually not production servers but
dev machines.

On my production machines i dont mind the problem of not being able to
connect to the host.

But on a dev machine connecting to services on the same host from inside a
container is exactly the scenario where this functionality is desired the
most.

@advoretsky

This comment has been minimized.

Show comment
Hide comment
@advoretsky

advoretsky May 30, 2016

I need this docker0 interface too for using in mixed "docker + on host (from IDE) running apps" environment.

advoretsky commented May 30, 2016

I need this docker0 interface too for using in mixed "docker + on host (from IDE) running apps" environment.

@justincormack

This comment has been minimized.

Show comment
Hide comment
@justincormack

justincormack Jun 1, 2016

Contributor

The current best solution is to connect to your containers from another container. At present there is no way we can provide routing to these containers due to issues with OSX that Apple have not yet resolved. we are tracking this requirement, but we cannot do anything about it at present.

Contributor

justincormack commented Jun 1, 2016

The current best solution is to connect to your containers from another container. At present there is no way we can provide routing to these containers due to issues with OSX that Apple have not yet resolved. we are tracking this requirement, but we cannot do anything about it at present.

@igrayson

This comment has been minimized.

Show comment
Hide comment
@igrayson

igrayson Jun 4, 2016

Is the above comment accurate?

I found that, from within docker-for-mac-beta containers, the docker host could be found and connected to at the usual 172.17.0.1 address (assuming the service bound to 0.0.0.0).

igrayson commented Jun 4, 2016

Is the above comment accurate?

I found that, from within docker-for-mac-beta containers, the docker host could be found and connected to at the usual 172.17.0.1 address (assuming the service bound to 0.0.0.0).

@cpuguy83

This comment has been minimized.

Show comment
Hide comment
@cpuguy83

cpuguy83 Jun 5, 2016

Contributor

@igrayson This is because the containers are in the VM with the docker daemon and can certainly access it.
The issue is routing from OSX into the VM net.

Contributor

cpuguy83 commented Jun 5, 2016

@igrayson This is because the containers are in the VM with the docker daemon and can certainly access it.
The issue is routing from OSX into the VM net.

@igrayson

This comment has been minimized.

Show comment
Hide comment
@igrayson

igrayson Jun 5, 2016

The issue is routing from OSX into the VM net.

That's not my understanding of the OP issue:

I would like to be able to connect to my local redis and other services without having to dockerize these...

I am running docker-for-mac-beta, and have no trouble connecting to redis and other local services -- running on OSX -- by having them listen on 0.0.0.0, and having my dockerized apps connect to 172.17.0.1.

igrayson commented Jun 5, 2016

The issue is routing from OSX into the VM net.

That's not my understanding of the OP issue:

I would like to be able to connect to my local redis and other services without having to dockerize these...

I am running docker-for-mac-beta, and have no trouble connecting to redis and other local services -- running on OSX -- by having them listen on 0.0.0.0, and having my dockerized apps connect to 172.17.0.1.

@thalesfsp

This comment has been minimized.

Show comment
Hide comment
@thalesfsp

thalesfsp Jun 8, 2016

Overview

I have the same problem. Using Docker version 1.11.1-beta14 (build: 8670) 984649fbd63d53a62b34f08b59694d4d569b74d5. My pinata doctor says everything is ok.

I cannot curl a service running in host, for example an ExpressJS application listening in the port 3001, from inside the container:

root@e19fc8e02595:/# curl localhost:3001
curl: (7) Failed to connect to localhost port 3001: Connection refused

root@e19fc8e02595:/# curl 0.0.0.0:3001
curl: (7) Failed to connect to 0.0.0.0 port 3001: Connection refused

root@e19fc8e02595:/# curl 172.25.8.25:3001
{"status":200} 
root@e19fc8e02595:/#

Note: 172.25.8.25 is my WiFi IP.

Pinata

$pinata list
These are advanced configuration settings to customize Docker.app on MacOSX.
You can set them via pinata set <key> <value> <options>.

🐳  hostname = docker
   Hostname of the virtual machine endpoint, where container ports will be
   exposed if using nat networking. Access it via 'docker.local'.

🐳  hypervisor = native (memory=4, ncpu=6)
   The Docker.app includes embedded hypervisors that run the virtual machines
   that power the containers. This setting allows you to control which the
   default one used for Linux is.

 ▸  native: a version of the xhyve hypervisor that uses the MacOSX
              Hypervisor.framework to run container VMs. Parameters:
              memory (VM memory in gigabytes), ncpu (vCPUs)


🐳  network = hostnet (docker-ipv4=192.168.65.2, host-ipv4=192.168.65.1)
   Controls how local containers can access the external network via the
   MacOS X host. This includes outbound traffic as well as publishing ports
   for external access to the local containers.

 ▸ hostnet: a mode that helps if you are using a VPN that restricts
              connectivity. Activating this mode will proxy container network
              packets via the Docker.app process as host socket traffic.
              Parameters: docker-ipv4 (docker node), host-ipv4 (host node)
 ▸     nat: a mode that uses the MacOS X vmnet.framework to route container
              traffic to the host network via a NAT.

🐳  filesystem = osxfs
   Controls the mode by which files from the MacOS X host and the container
   filesystem are shared with each other.

 ▸   osxfs: a FUSE-based filesystem that bidirectionally forwards OSX
              filesystem events into the container.


🐳  native/port-forwarding = true
   Expose container ports on the Mac, rather than the VM

 ▸    true: Container ports will be exposed on the Mac
 ▸   false: Container ports will be exposed on the VM

🐳  daemon = run 'pinata get daemon' or 'pinata set daemon [@file|-]>
   JSON configuration of the local Docker daemon. Configure any custom
   options you need as documented in:
   https://docs.docker.com/engine/reference/commandline/daemon/. Set it
   directly, or a @file or - for stdin.

Possible duplicates, references, help and etc

thalesfsp commented Jun 8, 2016

Overview

I have the same problem. Using Docker version 1.11.1-beta14 (build: 8670) 984649fbd63d53a62b34f08b59694d4d569b74d5. My pinata doctor says everything is ok.

I cannot curl a service running in host, for example an ExpressJS application listening in the port 3001, from inside the container:

root@e19fc8e02595:/# curl localhost:3001
curl: (7) Failed to connect to localhost port 3001: Connection refused

root@e19fc8e02595:/# curl 0.0.0.0:3001
curl: (7) Failed to connect to 0.0.0.0 port 3001: Connection refused

root@e19fc8e02595:/# curl 172.25.8.25:3001
{"status":200} 
root@e19fc8e02595:/#

Note: 172.25.8.25 is my WiFi IP.

Pinata

$pinata list
These are advanced configuration settings to customize Docker.app on MacOSX.
You can set them via pinata set <key> <value> <options>.

🐳  hostname = docker
   Hostname of the virtual machine endpoint, where container ports will be
   exposed if using nat networking. Access it via 'docker.local'.

🐳  hypervisor = native (memory=4, ncpu=6)
   The Docker.app includes embedded hypervisors that run the virtual machines
   that power the containers. This setting allows you to control which the
   default one used for Linux is.

 ▸  native: a version of the xhyve hypervisor that uses the MacOSX
              Hypervisor.framework to run container VMs. Parameters:
              memory (VM memory in gigabytes), ncpu (vCPUs)


🐳  network = hostnet (docker-ipv4=192.168.65.2, host-ipv4=192.168.65.1)
   Controls how local containers can access the external network via the
   MacOS X host. This includes outbound traffic as well as publishing ports
   for external access to the local containers.

 ▸ hostnet: a mode that helps if you are using a VPN that restricts
              connectivity. Activating this mode will proxy container network
              packets via the Docker.app process as host socket traffic.
              Parameters: docker-ipv4 (docker node), host-ipv4 (host node)
 ▸     nat: a mode that uses the MacOS X vmnet.framework to route container
              traffic to the host network via a NAT.

🐳  filesystem = osxfs
   Controls the mode by which files from the MacOS X host and the container
   filesystem are shared with each other.

 ▸   osxfs: a FUSE-based filesystem that bidirectionally forwards OSX
              filesystem events into the container.


🐳  native/port-forwarding = true
   Expose container ports on the Mac, rather than the VM

 ▸    true: Container ports will be exposed on the Mac
 ▸   false: Container ports will be exposed on the VM

🐳  daemon = run 'pinata get daemon' or 'pinata set daemon [@file|-]>
   JSON configuration of the local Docker daemon. Configure any custom
   options you need as documented in:
   https://docs.docker.com/engine/reference/commandline/daemon/. Set it
   directly, or a @file or - for stdin.

Possible duplicates, references, help and etc

@Kazanz

This comment has been minimized.

Show comment
Hide comment
@Kazanz

Kazanz Jul 15, 2016

I had similiar issues and found 172.* ips would not let me connect to a local mysql instance binded to 0.0.0.0.

I could connect to it with any routable IP address from my host machine. ifconfig and find one of yours.

Now how do I get this dynamically into the container?

Kazanz commented Jul 15, 2016

I had similiar issues and found 172.* ips would not let me connect to a local mysql instance binded to 0.0.0.0.

I could connect to it with any routable IP address from my host machine. ifconfig and find one of yours.

Now how do I get this dynamically into the container?

@nikdavis

This comment has been minimized.

Show comment
Hide comment
@nikdavis

nikdavis Jul 16, 2016

Having the same issue as @Kazanz (mysql running on locally/uncontained) trying 172.17.0.1. So I guess I'll try the Docker Toolbox? It would be helpful if this constraint was documented. I couldn't find anything about it until I stumbled upon this issue.

nikdavis commented Jul 16, 2016

Having the same issue as @Kazanz (mysql running on locally/uncontained) trying 172.17.0.1. So I guess I'll try the Docker Toolbox? It would be helpful if this constraint was documented. I couldn't find anything about it until I stumbled upon this issue.

@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah
Member

thaJeztah commented Jul 16, 2016

Ping @londoncalling ^^

@rioastamal

This comment has been minimized.

Show comment
Hide comment
@rioastamal

rioastamal Jul 20, 2016

Any news about this one? because in Ubuntu (host) the application inside container which listen on 0.0.0.0 can be contacted by the host using IP 172.17.*.*.. So no need to expose port when running the container.

On Docker for Mac Beta I can not do that because the absent of docker0. Hope it getting fixed on the final release :)

rioastamal commented Jul 20, 2016

Any news about this one? because in Ubuntu (host) the application inside container which listen on 0.0.0.0 can be contacted by the host using IP 172.17.*.*.. So no need to expose port when running the container.

On Docker for Mac Beta I can not do that because the absent of docker0. Hope it getting fixed on the final release :)

@londoncalling

This comment has been minimized.

Show comment
Hide comment
@londoncalling

londoncalling Jul 20, 2016

Contributor

@thaJeztah @astasoft I'll look into it today, thanks@

Contributor

londoncalling commented Jul 20, 2016

@thaJeztah @astasoft I'll look into it today, thanks@

@DanielSchwiperich DanielSchwiperich referenced this issue Nov 21, 2016

Closed

Update #16

3 of 3 tasks complete
@ChinaXing

This comment has been minimized.

Show comment
Hide comment
@ChinaXing

ChinaXing Dec 6, 2016

@justincormack you have not supply any solution to users of Docker for mac, the ip access is very demanded, because develop with docker need direct access to the container service from docker-container and from host, port forwarding not works for this situation ( the service will have different address from different place).

also the libvmnet not so fine, but it is a solution, sudo is acceptable than nothing !!!

the tap device solution need no-sudo permission. at least, docker for mac should supply some hack way to let developer make their way. for example , the hyperkit start command argument can be custom by users.

At now, The docker for mac is almost useless for people.

shit !

ChinaXing commented Dec 6, 2016

@justincormack you have not supply any solution to users of Docker for mac, the ip access is very demanded, because develop with docker need direct access to the container service from docker-container and from host, port forwarding not works for this situation ( the service will have different address from different place).

also the libvmnet not so fine, but it is a solution, sudo is acceptable than nothing !!!

the tap device solution need no-sudo permission. at least, docker for mac should supply some hack way to let developer make their way. for example , the hyperkit start command argument can be custom by users.

At now, The docker for mac is almost useless for people.

shit !

@dutchiexl

This comment has been minimized.

Show comment
Hide comment
@dutchiexl

dutchiexl Dec 20, 2016

Is there any sight on if or when this will be fixed ?

dutchiexl commented Dec 20, 2016

Is there any sight on if or when this will be fixed ?

@aPoCoMiLogin

This comment has been minimized.

Show comment
Hide comment
@aPoCoMiLogin

aPoCoMiLogin Dec 20, 2016

@justincormack: In addition this network setup would require root access which we are trying to avoid entirely in Docker for Mac (we currently have a very small root helper that we are trying to remove).

Why? On linux is not possible to run docker without root privileges and everything is fine, on OSX you want to avoid that. What is the reason behind that? So from now on docker for OSX should be like facebook app, it does not matter that core feature is not working, but it didn't require root privileges?

IMO if root privilege helps resolve that issue, then fix it and In the meantime try to achieve it without root. We are currently without core feature, that we used to, that we planned whole flow based on that feature, and now we need to resolve lots of issues.

aPoCoMiLogin commented Dec 20, 2016

@justincormack: In addition this network setup would require root access which we are trying to avoid entirely in Docker for Mac (we currently have a very small root helper that we are trying to remove).

Why? On linux is not possible to run docker without root privileges and everything is fine, on OSX you want to avoid that. What is the reason behind that? So from now on docker for OSX should be like facebook app, it does not matter that core feature is not working, but it didn't require root privileges?

IMO if root privilege helps resolve that issue, then fix it and In the meantime try to achieve it without root. We are currently without core feature, that we used to, that we planned whole flow based on that feature, and now we need to resolve lots of issues.

@jengo

This comment has been minimized.

Show comment
Hide comment
@jengo

jengo Dec 20, 2016

Would an acceptable compromise be to consider this an advanced feature. And when advanced features are enabled they require additional privileges ?

The reason I want this feature returned is to keep stuff on standard ports. We have a standard naming convention for all our services. I have DNS records created for even dev which could point to a static IP on their Mac. Each container get it's own IP, so it's always port 3306 no matter which project you are working with. Each project is truly separated just like it is in qa all the way to prd.

Now, when a developer wants to connect to MySQL on their local machine they have to look at a chart to see what unique port the project has. Project A is 3307, Project B is 3308 what was Project Q again ? Randomizing port is also sloppy because it doesn't allow you to save connection settings and such. You still need to look it up all the time.

While this might seem like a minor issue. Switching between projects very frequently is annoying, with this standardization it removes a lot of extra steps. You want to work on a different project ? Git clone and run make. EVERYTHING is setup from there on out. Multiple containers, credentials, configs, etc. Single command development setup.

jengo commented Dec 20, 2016

Would an acceptable compromise be to consider this an advanced feature. And when advanced features are enabled they require additional privileges ?

The reason I want this feature returned is to keep stuff on standard ports. We have a standard naming convention for all our services. I have DNS records created for even dev which could point to a static IP on their Mac. Each container get it's own IP, so it's always port 3306 no matter which project you are working with. Each project is truly separated just like it is in qa all the way to prd.

Now, when a developer wants to connect to MySQL on their local machine they have to look at a chart to see what unique port the project has. Project A is 3307, Project B is 3308 what was Project Q again ? Randomizing port is also sloppy because it doesn't allow you to save connection settings and such. You still need to look it up all the time.

While this might seem like a minor issue. Switching between projects very frequently is annoying, with this standardization it removes a lot of extra steps. You want to work on a different project ? Git clone and run make. EVERYTHING is setup from there on out. Multiple containers, credentials, configs, etc. Single command development setup.

@tknerr

This comment has been minimized.

Show comment
Hide comment
@tknerr

tknerr Jan 18, 2017

+1, desperately needed :-/

tknerr commented Jan 18, 2017

+1, desperately needed :-/

@iadknet

This comment has been minimized.

Show comment
Hide comment
@iadknet

iadknet Jan 26, 2017

I just caught up on the documentation at https://docs.docker.com/docker-for-mac/networking/ so I understand the challenges involved.

Unfortunately this is a severe impediment for using docker native in our local development environment. I had hoped to migrate away from Virtualbox/Vagrant.

Our issue is that we use Consul for service discovery. For local development we want to run a mix of services from docker-compose and directly from developer's IDEs on the Mac. Since services running in containers register with consul using their docker ip:port, services running outside of docker cannot integrate.

Of course this is also an issue in a multi-host cluster, but that is solved by either overlay networking (or in our case, an obnoxiously hackish introspection entrypoint script that figures out the host ip:port mappings).

It looks like an introspection API is finally being worked on to help solve this kind of issue (#7472). Hopefully that introspection API will work with docker for the mac/windows as well).

iadknet commented Jan 26, 2017

I just caught up on the documentation at https://docs.docker.com/docker-for-mac/networking/ so I understand the challenges involved.

Unfortunately this is a severe impediment for using docker native in our local development environment. I had hoped to migrate away from Virtualbox/Vagrant.

Our issue is that we use Consul for service discovery. For local development we want to run a mix of services from docker-compose and directly from developer's IDEs on the Mac. Since services running in containers register with consul using their docker ip:port, services running outside of docker cannot integrate.

Of course this is also an issue in a multi-host cluster, but that is solved by either overlay networking (or in our case, an obnoxiously hackish introspection entrypoint script that figures out the host ip:port mappings).

It looks like an introspection API is finally being worked on to help solve this kind of issue (#7472). Hopefully that introspection API will work with docker for the mac/windows as well).

@rogaha

This comment has been minimized.

Show comment
Hide comment
@rogaha

rogaha Feb 27, 2017

Contributor

hey guys, I think there is something that is worth sharing related to this thread, we are able to talk to the host machine from within the containers using the default IP created by Docker for Mac/Windows.

The IP is 192.168.65.1

You can test it by following the steps below:

rogaha@MacBook-Pro:~/development/rogaha$ docker run --name docker-nginx -p 80:80 -d nginx                                
4bc4818c49cffd7b4186294c71e6d4608c0482fd74521b3e9d03a14d499b3e6b
rogaha@MacBook-Pro:~/development/rogaha$

rogaha@MacBook-Pro:~/development/rogaha$ docker run -it --rm tutum/curl curl 192.168.65.1                                                                                   5:52:22
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
rogaha@MacBook-Pro:~/development/rogaha$

I hope it helps!

Contributor

rogaha commented Feb 27, 2017

hey guys, I think there is something that is worth sharing related to this thread, we are able to talk to the host machine from within the containers using the default IP created by Docker for Mac/Windows.

The IP is 192.168.65.1

You can test it by following the steps below:

rogaha@MacBook-Pro:~/development/rogaha$ docker run --name docker-nginx -p 80:80 -d nginx                                
4bc4818c49cffd7b4186294c71e6d4608c0482fd74521b3e9d03a14d499b3e6b
rogaha@MacBook-Pro:~/development/rogaha$

rogaha@MacBook-Pro:~/development/rogaha$ docker run -it --rm tutum/curl curl 192.168.65.1                                                                                   5:52:22
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
rogaha@MacBook-Pro:~/development/rogaha$

I hope it helps!

@gsong

This comment has been minimized.

Show comment
Hide comment
@gsong

gsong Feb 27, 2017

@rogaha That's interesting info. Is that documented somewhere? How did you find out about it?

I've confirmed locally on my Mac that it does indeed reach all the way to the host (not just another Docker container) via 192.168.65.1.

gsong commented Feb 27, 2017

@rogaha That's interesting info. Is that documented somewhere? How did you find out about it?

I've confirmed locally on my Mac that it does indeed reach all the way to the host (not just another Docker container) via 192.168.65.1.

@rogaha

This comment has been minimized.

Show comment
Hide comment
@rogaha

rogaha Feb 27, 2017

Contributor

I'm not sure. @thaJeztah @justincormack do you happen to know?

Contributor

rogaha commented Feb 27, 2017

I'm not sure. @thaJeztah @justincormack do you happen to know?

@justincormack

This comment has been minimized.

Show comment
Hide comment
@justincormack

justincormack Feb 27, 2017

Contributor
Contributor

justincormack commented Feb 27, 2017

@cristiangrama

This comment has been minimized.

Show comment
Hide comment
@cristiangrama

cristiangrama Mar 30, 2017

@rogaha 192.168.65.1 is not working on my end. How did you find out about that IP?

cristiangrama commented Mar 30, 2017

@rogaha 192.168.65.1 is not working on my end. How did you find out about that IP?

@geerlingguy

This comment has been minimized.

Show comment
Hide comment
@geerlingguy

geerlingguy May 5, 2017

I just wanted to add a +1/subscribe along with everyone else in this thread, and add another voice to the feature request of being able to easily access docker containers through the bridge interface on unique/custom IP addresses.

I was ramming my head into the wall for at least 4 hours trying to figure out why I couldn't get any documented examples working, until I somehow found this issue, describing the problem perfectly.

For now, the workaround mentioned by @justincormack (#22753 (comment)) seems to work passably well. I'm adding experimental Docker support to Drupal VM using the instructions:

  1. Add a host to /etc/hosts with sudo /etc/hosts (e.g. 192.168.1.100 mysite.dev)

  2. Create an alias on the loopback interface: sudo sudo ifconfig lo0 alias 192.168.1.100/24

  3. Bring up a container with the following pseudocompose:

     version: "3"
     
     services:
       app:
         image: image-name
         ports:
           - 192.168.1.100:80:80
           - 192.168.1.100:443:443
         [...]
    

This seems to work perfectly for me, and though it currently requires a couple manual steps (which are avoided if using other tools on top of Docker... something I don't want to force my users to do), it allows me to almost reach Docker nirvana on Mac.

So thanks for the workaround, and I hope you can find a way to get the bridge network working soon (or just abandon macOS < 10.12 😏)

geerlingguy commented May 5, 2017

I just wanted to add a +1/subscribe along with everyone else in this thread, and add another voice to the feature request of being able to easily access docker containers through the bridge interface on unique/custom IP addresses.

I was ramming my head into the wall for at least 4 hours trying to figure out why I couldn't get any documented examples working, until I somehow found this issue, describing the problem perfectly.

For now, the workaround mentioned by @justincormack (#22753 (comment)) seems to work passably well. I'm adding experimental Docker support to Drupal VM using the instructions:

  1. Add a host to /etc/hosts with sudo /etc/hosts (e.g. 192.168.1.100 mysite.dev)

  2. Create an alias on the loopback interface: sudo sudo ifconfig lo0 alias 192.168.1.100/24

  3. Bring up a container with the following pseudocompose:

     version: "3"
     
     services:
       app:
         image: image-name
         ports:
           - 192.168.1.100:80:80
           - 192.168.1.100:443:443
         [...]
    

This seems to work perfectly for me, and though it currently requires a couple manual steps (which are avoided if using other tools on top of Docker... something I don't want to force my users to do), it allows me to almost reach Docker nirvana on Mac.

So thanks for the workaround, and I hope you can find a way to get the bridge network working soon (or just abandon macOS < 10.12 😏)

@TheAntonioReyes

This comment has been minimized.

Show comment
Hide comment
@TheAntonioReyes

TheAntonioReyes May 5, 2017

@rogaha thank you sooo much, 192.168.65.1 has solved my issue. I hope this doesn't get changed in the future, unless they find a cleaner solution. As of Docker for Mac 17.0.3.1 this has allowed my container to talk to the MySQL server running on my machine's localhost.

TheAntonioReyes commented May 5, 2017

@rogaha thank you sooo much, 192.168.65.1 has solved my issue. I hope this doesn't get changed in the future, unless they find a cleaner solution. As of Docker for Mac 17.0.3.1 this has allowed my container to talk to the MySQL server running on my machine's localhost.

@rogaha

This comment has been minimized.

Show comment
Hide comment
@rogaha

rogaha May 5, 2017

Contributor

@TheAntonioReyes I'm glad it worked for you. Thanks for the feedback!

Contributor

rogaha commented May 5, 2017

@TheAntonioReyes I'm glad it worked for you. Thanks for the feedback!

@diemol

This comment has been minimized.

Show comment
Hide comment
@diemol

diemol Jul 7, 2017

Hi,

I am reading the docs here: https://docs.docker.com/docker-for-mac/networking/#use-cases-and-workarounds, and I am trying to use the the special Mac-only DNS name mentioned there: docker.for.mac.localhost.

If I do a ping on a terminal inside the docker container, it gets resolved to 192.168.65.1, and doing a curl to an app running on my mac retrieves the expected result.

I am using this image: https://github.com/elgalu/docker-selenium, and I can open a Chrome browser there. So I wanted to go to http://docker.for.mac.localhost:80, and the connection was refused. However, doing http://192.168.65.1:80 works.

Am I missing something? I wanted to start using the docker.for.mac.localhost.

I am using this: Version 17.06.0-ce-mac18 (18433)

EDIT: Seems this only happens on Chrome and this issue explains it. docker/for-mac#1837

diemol commented Jul 7, 2017

Hi,

I am reading the docs here: https://docs.docker.com/docker-for-mac/networking/#use-cases-and-workarounds, and I am trying to use the the special Mac-only DNS name mentioned there: docker.for.mac.localhost.

If I do a ping on a terminal inside the docker container, it gets resolved to 192.168.65.1, and doing a curl to an app running on my mac retrieves the expected result.

I am using this image: https://github.com/elgalu/docker-selenium, and I can open a Chrome browser there. So I wanted to go to http://docker.for.mac.localhost:80, and the connection was refused. However, doing http://192.168.65.1:80 works.

Am I missing something? I wanted to start using the docker.for.mac.localhost.

I am using this: Version 17.06.0-ce-mac18 (18433)

EDIT: Seems this only happens on Chrome and this issue explains it. docker/for-mac#1837

@atuttle

This comment has been minimized.

Show comment
Hide comment
@atuttle

atuttle Aug 31, 2017

I think that using docker.for.mac.localhost was a poor decision. The whole point of containers is that they are portable and should have no dependency on what type of host they reside. If my team is half Windows users and half Mac, then the code inside of our containers will have to be configured differently.

I'm glad there's a hostname approach, I just think the meeting where this approach was decided should have lasted 5 more minutes.

atuttle commented Aug 31, 2017

I think that using docker.for.mac.localhost was a poor decision. The whole point of containers is that they are portable and should have no dependency on what type of host they reside. If my team is half Windows users and half Mac, then the code inside of our containers will have to be configured differently.

I'm glad there's a hostname approach, I just think the meeting where this approach was decided should have lasted 5 more minutes.

@SeanCannon

This comment has been minimized.

Show comment
Hide comment
@SeanCannon

SeanCannon commented Sep 18, 2017

@AbimbolaE

This comment has been minimized.

Show comment
Hide comment
@AbimbolaE

AbimbolaE Oct 30, 2017

I worked around this problem by reverting back to docker-machine for Mac. The docker machine VM is a Linux distro which means that it creates a docker0 interface which has access to the private network range of the docker containers. Then, on my host mac machine, I created a route for the 172.18.x.x address range of the containers which points to the ip address of the docker machine instance (192.168.99.100 in my case).

This allows packets destined for the private container network to be forwarded by my mac OS to the IP address of the linux VM of docker machine, which knows how to reach the private containers and forwards the packets to them directly.

Creating the route to the docker machine vm for the private container network

sudo route -n add -net 172.18.0.0/16 192.168.99.100

You can get the address for the container network by using docker network inspect or docker inspect <container_name>.

AbimbolaE commented Oct 30, 2017

I worked around this problem by reverting back to docker-machine for Mac. The docker machine VM is a Linux distro which means that it creates a docker0 interface which has access to the private network range of the docker containers. Then, on my host mac machine, I created a route for the 172.18.x.x address range of the containers which points to the ip address of the docker machine instance (192.168.99.100 in my case).

This allows packets destined for the private container network to be forwarded by my mac OS to the IP address of the linux VM of docker machine, which knows how to reach the private containers and forwards the packets to them directly.

Creating the route to the docker machine vm for the private container network

sudo route -n add -net 172.18.0.0/16 192.168.99.100

You can get the address for the container network by using docker network inspect or docker inspect <container_name>.

@arefaslani

This comment has been minimized.

Show comment
Hide comment
@arefaslani

arefaslani Jun 27, 2018

You can find ip of the host in docker for mac by running this command:

docker run busybox ping -c 1 docker.for.mac.localhost | awk 'FNR==2 {print $4}' | sed s'/.$//'

arefaslani commented Jun 27, 2018

You can find ip of the host in docker for mac by running this command:

docker run busybox ping -c 1 docker.for.mac.localhost | awk 'FNR==2 {print $4}' | sed s'/.$//'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment