Comments (6)
Thanks for the feedback, I'll let you know what I end up doing. And sounds good on closing this!
from docker-mac-network.
I found a solution for this but am working on making it less manual and more elegant... Had to make some tweaks to the docker vm's iptables. Will share the solution when it's tidied up.
from docker-mac-network.
@phutchins For this you can simply expose each service on a random port. The service will still be reachable on the original port at the internal container IP. The random port only applies to port forwarding on the host interface. The port within the container is not affected.
For example, if you expose port 80 with ports: ["80"]
, it will be assigned a random port on your macOS localhost, but you can still reach this service at something like172.20.0.10:80
through the VPN and from other containers within the same Docker network.
from docker-mac-network.
@wojas awesome! This is a much cleaner solution and is built into docker... Didn't realize that exposing a random port would create the iptables rules so thats perfect. I've tried it out and it works quite nicely.
I'd like to build this into a generic opensource framework for project development... One of the other things that I'd like to accomplish with it is exposing hosts over the VPN via DNS by their hostname. Have you used any of the existing solutions for DNS in docker/docker-compose by chance?
from docker-mac-network.
@phutchins I have not used any third party solution to also expose DNS on the macOS host (not aware of any), but it is an interesting idea.
One possible approach would be to use PowerDNS recursor or dnsdist's Lua support to resolve against Docker APIs for say a .docker TLD (and hope that this TLD won't get registered in the future), while passing through normal queries.
This can only work with one VPN connection, or if you use a special DNS container just for this.
from docker-mac-network.
I'm closing this issue, as it works out of the box with exposed ports.
from docker-mac-network.
Related Issues (13)
- Split DNS proxy to docker embedded dns HOT 1
- Issue with socat and ncurses
- Can't connect to containers HOT 1
- openvpn:latest image doesn't work with client config HOT 2
- VERIFY ERROR
- How to access nginx through browser
- iptables v1.8.4 (legacy): can't initialize iptables table `nat': iptables who? (do you need to insmod?) HOT 4
- Make Docker internal DNS name resolution service available to OSX through the VPN HOT 1
- Can't access containers HOT 1
- Can't access containers in the internal Docker bridge network HOT 3
- Still can't connect HOT 1
- Missing docker-for-mac.ovpn HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docker-mac-network.