Coder Social home page Coder Social logo

mystix / docker-dns Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zanaca/docker-dns

0.0 1.0 0.0 1.53 MB

DNS server for your docker containers. Allowing you to access them with a domain name, without exposing ANY port. Allowing access from you linux, mac or windows browser!

License: MIT License

Shell 1.32% Makefile 1.78% Smarty 5.14% Dockerfile 4.23% Python 87.52%

docker-dns's Introduction

Docker DNS for containers and host machine

Docker DNS creates a container that works as a DNS for docker containers in you machine. Every running container will be accessible by $container_name.docker for example. You could inform you own domain if you like. Your domains are available inside and outside docker, but just for you machine. For example, you could access http://nginx.docker from your browser window OR from inside a container.

It was created to allow you to work in a container as if was a "real" server setup. You will have access to all ports/services inside the container without need to expose all the ports. You can publish ports as well to access it like the old way. E.g.: 127.0.0.1:8080 -> container_ip:80

It was tested on linux and macOS Catalina. macOS environment has a downside that you will always run the ./bin/docker-dns tunnel every time you boot the host machine. An service will be installed and loaded on every boot to handle that necessity or you can run the application 'dockerdns-tunnel', available on ~/Applications.

The main usage is for development environment only, should not be used in production environment.

By default it will enable create that hosts: ns0.docker and ns0.$YOUR_HOSTNAME.docker.

Requirements for host machine

Tested enviroment

  • Docker 19.03.13
  • Ubuntu: 20.04
  • Linux Mint: 20, 20.1
  • macOS: Catalina, Big Sur
  • Windows: 10 (WSL2 - Ubuntu)

You can see a list of older OSes on version 1.x

On Windows you don't have to install Docker inside WSL2 linux, you should work with Docker for windows and enable WSL2 integration.

* Windows caveat

For Windows a socks5 proxy (using ssh to container ns0) will be used to handle the address from host machine to docker network. Only addresses from 172.16.0.0 to 172.31.255.255 will be redirect to proxy. You will not be able to run a different proxy while using docker-dns. The socks5 proxy address is 127.0.0.1 using port 31080

Install

For an simple installation process, paste the command in a macOS Terminal, Linux or WSL shell prompt.

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/zanaca/docker-dns/install/run.sh)"
  • The script will place docker-dns inside /usr/local/docker-dns

Or you can checkout the code in any folder of your choice and:

  • Install all python dependencies by running $ pip3 install -r requirements.txt
  • Execute $ ./bin/docker-dns install

Supported commands

  • install - Set up all environment;

  • uninstall - Remove configuration files from your system;

  • show-domain - Show the working domain of your installation;

  • tunnel - Create a tunnel to route all traffic to you docker containers. Available only in macOS, on linux you don't need that feature;

  • status - Show the current status for your machine.

You can see the list of all available commands and options running $ ./bin/docker-dns -h

Options

On install command you can pass some variables to change how setup is done. You can change the working domain for example.

  • tld: working domain. It can be any domain name but the domains designed to work in loopback network. For example yourmachine.dev will create names like CONTAINER_NAME.yourmachine.dev. You can have docker.your_real_domain.com as well so it will create names like CONTAINER_NAME.docker.your_real_domain.com . Default value: docker`;

  • tag: Tag name for the created docker image. It should be changed only if you have a name conflict Default value: ns0;

  • name: Running container name. Default value: the tag value.

Example:

$ ./bin/docker-dns install tld=docker.dev tag=dns

Will create a docker image name dns and it will be available as dns.docker.dev so you could run dig www.google.com @dns.docker.dev

Troubleshooting

If you are using macOS or Windows, on restart, you can will loose access to your containers DNS. You need to recreate a tunnel to route all traffic to docker network through it on every boot. Just execute sudo ./bin/docker-dns tunnel from docker-dns folder

License

MIT

Thanks

docker-dns's People

Contributors

bernardolm avatar danielpucci avatar jorge-luiz-jr avatar maypimentel avatar renatovico avatar rodrigosdo avatar saboya avatar yagotome avatar zanaca avatar

Watchers

 avatar

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.