GitHub: mrfleshka/docker-hoster
A simple "etc/hosts" file injection tool to resolve names of local Docker containers on the host.
You need to create network for detect container aliases:
docker network create _develope
Then you need to register docker-hoster.
For Windows it looks like:
docker run -d --restart=always --name docker-hoster -v /var/run/docker.sock:/tmp/docker.sock:ro -v /c/Windows/System32/drivers/etc/hosts:/tmp/hosts mrfleshka/docker-hoster python -u hoster.py --networks _develope --masks .test
Also, for Windows you need to give your current user full access to file C:/Windows/System32/drivers/etc/hosts
(cuz docker-hoster will modify it later).
After this run you never return to starting docker-hoster (it will start automatically).
Next, in the docker-compose.yml
file, you need to add your network as external and set up aliases for the containers:
version: '3'
services:
nginx:
image: 'nginx:latest'
container_name: nginx-test
volumes:
- './.docker/nginx/conf:/etc/nginx/conf.d'
- '.:/var/www/app'
- './.docker/nginx/logs:/var/log/nginx'
ports:
- ${DOCKER_PORT_HTTP}:80
networks:
development:
aliases:
- mydomain.test
networks:
development:
external:
name: _develope
Be sure your aliases finish with .test
and written in _develope
network.
And if docker-compose up
for previous config, you will see next in your hosts:
#-----------Docker-Hoster-Domains----------
127.0.0.1 mydomain.test
#-----Do-not-add-hosts-after-this-line-----
You still need set up PORTS in config, but now you have dynamically updated aliasing system)
Docker Hub: mrfleshka/docker-hoster
docker build -t mrfleshka/docker-hoster .
docker tag mrfleshka/docker-hoster mrfleshka/docker-hoster:VERSION
docker push -a mrfleshka/docker-hoster