Skip to content

Update automatically your `/etc/hosts` to access running containers.

Notifications You must be signed in to change notification settings

annavanbiemen/docker-hostmanager

 
 

Repository files navigation

docker-hostmanager

ABOUT

Update automatically your /etc/hosts to access running containers. Inspired by vagrant-hostmanager.

Project homepage: https://github.com/iamluc/docker-hostmanager

USAGE

Linux

The easiest way is to use the docker image

$ docker run -d --name docker-hostmanager --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /etc/hosts:/hosts iamluc/docker-hostmanager

Note: the --restart=always option will make the container start automatically with your computer (recommended).

Mac OS

Download the PHAR executable here : https://github.com/iamluc/docker-hostmanager/releases

And then run it:

$ sudo php docker-hostmanager.phar synchronize-hosts

Note: We run the command as root as we need the permission to write file /etc/hots. If you don't want to run the command as root, grant the correct permission to you user.

Before running the command, don't forget to export your docker environment variables. i.e.

$ eval $(docker-machine env mybox)

Also, you should add a route to access containers inside your VM.

$ sudo route -n add 172.0.0.0/8 $(docker-machine ip $(docker-machine active))

INSTALL WITH COMPOSER

Alternatively, you can install docker-hostmanager with composer.

Just run

composer global require iamluc/docker-hostmanager

OPTIONS

The DOMAIN_NAME environment variable lets you define multiple hosts when running your containers. i.e.

$ docker run -d -e DOMAIN_NAME=test.com,www.test.com my_image

Tests

To run test, execute the following command : vendor/bin/phpunit

LICENSE

MIT

About

Update automatically your `/etc/hosts` to access running containers.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%