Giter VIP home page Giter VIP logo

Comments (6)

phutchins avatar phutchins commented on June 12, 2024 1

Thanks for the feedback, I'll let you know what I end up doing. And sounds good on closing this!

from docker-mac-network.

phutchins avatar phutchins commented on June 12, 2024

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.

wojas avatar wojas commented on June 12, 2024

@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.

phutchins avatar phutchins commented on June 12, 2024

@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.

wojas avatar wojas commented on June 12, 2024

@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.

wojas avatar wojas commented on June 12, 2024

I'm closing this issue, as it works out of the box with exposed ports.

from docker-mac-network.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.