Public Repository

Last pushed: 12 days ago
Short Description
Multicast DNS support for easier hostname access using docker-machine/boot2docker
Full Description

It can be frustrating to spin up a Virtualbox VM with docker-machine and then if you want to interact with your services, you have to either

  • A) manually forward ports, or
  • B) look up the machine's IP

Instead, use Avahi to resolve local DNS so you can access services running in your docker-machine VM at my-machine-name.local.

It's required that the host have Bonjour (pre-installed on all Macs) or some other mDNS client installed.

In docker-compose, include the layer with:

version: '2'
services:
    avahi:
        image: enernoclabs/avahi:latest
        network_mode: "host"
Docker Pull Command
Owner
enernoclabs

Comments (4)
mightyroser
8 months ago

From within the docker-machine VM, can I resolve .local names of other machines on my network?

For example, suppose I have vm1 which is a docker-machine VM running a enernoclabs/avahi container and another machine, named other-machine, which is also running avahi.

other-machine can resolve vm1.local. Should vm1 also be able to resolve other-machine.local?

Forgive me if this is a stupid question. I don't have a firm understanding of how avahi works.

volkertb
a year ago

@cghome Your docker-compose.yml V2 example didn't work. Apparently, in later versions of Docker Compose, you need to replace "net:" with "network_mode:". So the Avahi part of your example would be as follows:

version: '2'
services:
    avahi:
        image: enernoclabs/avahi:latest
        network_mode: "host"

With thanks to https://stackoverflow.com/a/35960507

volkertb
a year ago

Thank you so much for this very useful Docker image! 😄

For those who'd like to quickly try this out on their current Docker machine without having to write a Docker compose script first, you can quickly start an instance as follows:

docker run --net host --name "avahi" -d enernoclabs/avahi

Now you should be able to ping the Docker machine VM from the host that is running the boot2docker VM, simply by its hostname appended with the TLD ".local":

ping $DOCKER_MACHINE_NAME.local

Pinging the Docker machine like this should now also work inside any other VMs that are connected to the same host-only adapter to which the Docker machine is connected.

If the Docker machine ever goes down, you can quickly restart the Avahi daemon as follows:

docker start avahi

The instructions above will probably be obvious to experienced Docker users, but as a beginning user myself, I figured it'd be as useful to other beginners as it was to me.

I hope you didn't mind me tweeting this as well: https://twitter.com/volkertb/status/777120785878151170

Thanks again!

cghome
a year ago

Hi,

Please add support for docker-compose.yml version-2 file and a real world example.

Thx Chris

Sample:

version: '2'
services:
    avahi:
        image: enernoclabs/avahi:latest
        net: "host"
    homebridge:
        build: .
        image: cghome/homebridge-pm2
        container_name: homebridge-pm2