jarylc / Docker-Hosts-Sync

Synced from GitLab - Lightweight Docker image to synchronize Docker host's /etc/hosts file with Docker on container start and destruction.

Home Page:https://gitlab.com/jarylc/docker-hosts-sync

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Docker Hosts Sync Logo

Docker Hosts Sync

Lightweight Docker image to synchronize Docker host's /etc/hosts file with Docker on container start and destruction.

Docker Hub Image »

Explore the docs »

Report Bugs · Request Features

About The Project

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!

Features

  • 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 Variables

Environment Default value Description
EXIT_RESET 1 Reset /etc/hosts on exit

Built With

Getting Started

To get a local copy up and running follow these simple steps.

Docker Run

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-compose

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

Development

Building

$ cd /path/to/project/folder
$ go build -ldflags="-w -s"

Docker build

$ cd /path/to/project/folder
$ docker build .

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Feel free to fork the repository and submit pull requests.

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Jaryl Chng - git@jarylchng.com

https://jarylchng.com

Project Link: https://gitlab.com/jarylc/docker-hosts-sync/

About

Synced from GitLab - Lightweight Docker image to synchronize Docker host's /etc/hosts file with Docker on container start and destruction.

https://gitlab.com/jarylc/docker-hosts-sync

License:MIT License


Languages

Language:Go 77.2%Language:Shell 18.4%Language:Dockerfile 4.4%