Lightweight Docker image to synchronize Docker host's /etc/hosts file with Docker on container start and destruction.
Report Bugs · Request Features
This application makes possible to communicate via network with Docker containers via their container names on the Docker host. It's like as though you were communicating with another container within one!
- Super lightweight, final docker image based on
scratch
! - Updates only on container start and destruction, doesn't waste resources by checking periodically (i.e. every 5 seconds).
EXIT_RESET
flag to set if changes to/etc/hosts/
should be reset on exit.
Environment | Default value | Description |
---|---|---|
EXIT_RESET | 1 | Reset /etc/hosts on exit |
To get a local copy up and running follow these simple steps.
docker run -d \
--name docker-hosts-sync \
--privileged \
-e EXIT_RESET=1 \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v /etc/hosts:/etc/hosts \
--restart unless-stopped \
jarylc/docker-hosts-sync
docker-hosts-sync:
image: jarylc/docker-hosts-sync
privileged: true
environment:
- EXIT_RESET=1
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /etc/hosts:/etc/hosts
restart: unless-stopped
$ cd /path/to/project/folder
$ go build -ldflags="-w -s"
$ cd /path/to/project/folder
$ docker build .
See the open issues for a list of proposed features (and known issues).
Feel free to fork the repository and submit pull requests.
Distributed under the MIT License. See LICENSE
for more information.
Jaryl Chng - [email protected]
Project Link: https://gitlab.com/jarylc/docker-hosts-sync/