webproject-xyz/docker-hostsfile-sync
最新稳定版本:1.6.0
Composer 安装命令:
composer require webproject-xyz/docker-hostsfile-sync
包简介
A PHP docker API client with a cli tool to sync your hosts file with running docker containers to add hostnames for every network like '172.16.238.100 jwilder-proxy.docker jwilder-proxy.proxyNet jwilder.proxyNet proxy.local.proxyNet'
README 文档
README
A PHP docker API client with a cli tool to sync your hosts file with running docker containers to add hostnames for every network (inspired by https://github.com/iamluc/docker-hostmanager)
Example
bin/docker-api --help # ## add --hosts_file=/etc/hosts and run with sudo to sync file OR see result in ./tmp-hosts if not # # use php 8.3 with symfony cli symfony php bin/docker-api synchronize-hosts -v --reverse-proxy-host-ip=172.16.238.100 # on php 8.3+ php bin/docker-api synchronize-hosts -v --reverse-proxy-host-ip=172.16.238.100
hosts file (/etc/hosts) sync
Docker Compose/Podman Compose
docker compose up -d
# see logs
docker compose logs -f
Docker/Podman
docker pull ghcr.io/webproject-xyz/docker-hosts-file-sync:latest
docker run -d --name docker-hostfile-sync --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /etc/hosts:/app/hosts ghcr.io/webproject-xyz/docker-hosts-file-sync:latest
# or with reverse-proxy-ip e.g. "172.16.238.100"
docker run -d --name docker-hostfile-sync --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /etc/hosts:/app/hosts ghcr.io/webproject-xyz/docker-hosts-file-sync:latest --reverse-proxy-host-ip=172.16.238.100
Example of hosts file
This is based on 2 containers
- container 1 (jwilder-proxy) has multiple aliases
- container 2 (actual_server) has multiple aliases, an alias with a "normal" url (actual.realFancyUrl.tld set on the proxyNet network)
[...your stuff]
## docker-hostsfile-sync
# container - reverse proxy
172.16.238.100 proxy.local
# container - default network
172.19.0.2 actual_server.docker actual_server.actual-server_default
# container - proxyNet network (reverse proxy net)
172.16.238.2 actual_server.proxyNet
# reverse proxy entry from container env var: DOMAIN_NAME (multiple possible with)
# and reverse proxy entry from container network alias (with dot like "actual.my-reverse-proxy-url.xyz")
172.16.238.100 actual.my-reverse-proxy-url.xyz dev-actual.my-reverse-proxy-url.xyz
## docker-hostsfile-sync-end
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-04