All Projects → grachevko → docker-hosts-updater

grachevko / docker-hosts-updater

Licence: other
Automatic update /etc/hosts on start/stop containers.

Programming Languages

python
139335 projects - #7 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to docker-hosts-updater

Dns Proxy Server
Solve your DNS hosts from your docker containers, then from your local configuration, then from internet
Stars: ✭ 480 (+1233.33%)
Mutual labels:  dns, service-discovery
Nacos
an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.
Stars: ✭ 20,691 (+57375%)
Mutual labels:  dns, service-discovery
CoSky
High-performance, low-cost microservice governance platform. Service Discovery and Configuration Service | 高性能、低成本微服务治理平台
Stars: ✭ 57 (+58.33%)
Mutual labels:  dns, service-discovery
Vagrant Hostmanager
📝 A Vagrant plugin that manages hosts files within a multi-machine environment.
Stars: ✭ 1,442 (+3905.56%)
Mutual labels:  dns, development-environment
emperor-os
(new released v2.5 LTS.2022-06-25) It has focused on developing an All in One operating system for programming, designing and data science.Emperor-OS has over 500 apps and important tools
Stars: ✭ 32 (-11.11%)
Mutual labels:  development-environment
usbip-service-discovery
USB/IP Service Discovery - Provide GUI and some enhancement for USB/IP userspace
Stars: ✭ 25 (-30.56%)
Mutual labels:  service-discovery
spring-cloud-marathon
Spring Cloud integration with Mesos and Marathon
Stars: ✭ 29 (-19.44%)
Mutual labels:  service-discovery
docker-php
Docker build php development environment
Stars: ✭ 40 (+11.11%)
Mutual labels:  development-environment
ocaml-dns
OCaml implementation of the DNS protocol
Stars: ✭ 93 (+158.33%)
Mutual labels:  dns
fastdns
Fast DNS package for Go. Tuned for high performance. Zero memory allocations in almost paths. Up to 1M QPS on a single host.
Stars: ✭ 67 (+86.11%)
Mutual labels:  dns
ansible-role-dns
Install and configure dns on your system.
Stars: ✭ 39 (+8.33%)
Mutual labels:  dns
hazelcast-consul-discovery-spi
Consul based discovery strategy SPI for Hazelcast enabled applications
Stars: ✭ 47 (+30.56%)
Mutual labels:  service-discovery
python-zeroconf
A pure python implementation of multicast DNS service discovery
Stars: ✭ 468 (+1200%)
Mutual labels:  service-discovery
wordless gem
The quickest CLI tool to setup a new WordPress locally. Wordless ready.
Stars: ✭ 38 (+5.56%)
Mutual labels:  development-environment
dohjs
DNS over HTTPS client for use in the browser
Stars: ✭ 71 (+97.22%)
Mutual labels:  dns
module-admin-auto-login
No description or website provided.
Stars: ✭ 21 (-41.67%)
Mutual labels:  development-environment
Dumb
Dumain Bruteforcer - a fast and flexible domain bruteforcer
Stars: ✭ 54 (+50%)
Mutual labels:  dns
djit.su
Reactive Editor
Stars: ✭ 38 (+5.56%)
Mutual labels:  development-environment
multi-site-docker
A multi-site-docker configuration featuring nginx, php and mysql
Stars: ✭ 85 (+136.11%)
Mutual labels:  development-environment
balboa
server for indexing and querying passive DNS observations
Stars: ✭ 42 (+16.67%)
Mutual labels:  dns

docker-hosts-updater

Automatic update /etc/hosts on start/stop containers by labels.

Requirements

  • Native linux
    This tool has no effect on macOS or windows, because docker on these OS run in VM and you can't directly access from host to each container via ip. Yet you can pass traffic through loadbalancer, see section above.

Usage

Start up docker-hosts-updater:

$ docker run -d --restart=always \
    --name docker-hosts-updater \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v /etc/hosts:/opt/hosts \
    grachevko/docker-hosts-updater

Start containers with label ru.grachevko.dhu option

% docker run -d --label ru.grachevko.dhu=nginx.local nginx

Try to ping from host

% ping nginx.local

Default hosts

By default adding records with container name and container hostname. To disable it you can use environments CONTAINER_HOSTNAME_DISABLED and CONTAINER_NAME_DISABLED:

$ docker run -d --restart=always \
    --name docker-hosts-updater \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v /etc/hosts:/opt/hosts \
    -e CONTAINER_HOSTNAME_DISABLED=false \
    -e CONTAINER_NAME_DISABLED=false \
    grachevko/docker-hosts-updater

Multiple Hosts

You can add multiple hosts, just separate them by semicolon:

$ docker run --label ru.grachevko.dhu="nginx.local;nginx.ru" nginx
$ ping nginx.local
$ ping nginx.ru

Subdomains

Add subdomains by using pattern {www,api}.nginx.local:

$ docker run -d --label ru.grachevko.dhu="{www,api}.nginx.local" nginx
$ ping nginx.local
$ ping www.nginx.local
$ ping api.nginx.local

Priority

If you want to run two containers with same hosts and want one override another, just add priority after colon:

$ docker run -d --label ru.grachevko.dhu="nginx.local" nginx
$ docker run -d --label ru.grachevko.dhu="nginx.local:10" nginx
$ ping nginx.local

Container with greater priority will be used. Default priority 0. If priority is the same then early created container will be used.

Load Balancer

In order to pass the traffic through the loadbalancer you should define container's name or valid IPv4. Just add one more colon and container name after it.

$ docker run -d --name lb nginx
$ docker run -d --label ru.grachevko.dhu="nginx1.local:0:lb" nginx
$ docker run -d --label ru.grachevko.dhu="nginx2.local:0:127.0.0.1" nginx
$ ping nginx1.local // ip of lb
$ ping nginx2.local // ip of lb

Keep in mind, loadbalancer container must have fixed name.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].