<commit_before>docker-hostname-ping
====================

On a stock installation of Ubuntu based distributions comes with dnsmasq via NetworkManager. We can take advantage of this to generate a new file like `/etc/hosts` called `/etc/hosts.docker` which is read by `dnsmasq` for instant DNS updates on containers statuses.

In action:

    $ docker start stupefied_pare
    stupefied_pare
    $ docker ps
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    fa5a5785d4ea        example:latest   /bin/bash           3 weeks ago         Up About a minute                       stupefied_pare      
    $ cat /etc/hosts.docker 
    # Docker hosts. This file is auto-generated by /home/jay/bin/rebuild_docker_hosts.py on each docker
    # invocation.
    #
    # Last updated: Sat Aug 30 18:41:23 2014 with 1 running containers

    172.17.0.4  example.com
    $ ping -c1 example.com
    PING example.com (172.17.0.4) 56(84) bytes of data.
    64 bytes from example.com (172.17.0.4): icmp_seq=1 ttl=64 time=0.085 ms

    --- example.com ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 0.085/0.085/0.085/0.000 ms

## Installation

There are few parts that need to be installed.

* copy `additional-dnsmasq.conf` to `/etc/NetworkManager/dnsmasq.d/docker`
* add the contents of docker-bashrc.sh to your `.bashrc`
* copy `rebuild_docker_hosts.py` to your `bin` (e.g. `$HOME/bin` or `/usr/local/bin`)
* enable your user to sudo to `nobody` without a password (I have a docker group, so I use `%docker ALL=(nobody) NOPASSWD: ALL`)<commit_msg>Update README to create /etc/hosts.docker<commit_after>docker-hostname-ping
====================

On a stock installation of Ubuntu based distributions comes with dnsmasq via NetworkManager. We can take advantage of this to generate a new file like `/etc/hosts` called `/etc/hosts.docker` which is read by `dnsmasq` for instant DNS updates on containers statuses.

In action:

    $ docker start stupefied_pare
    stupefied_pare
    $ docker ps
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    fa5a5785d4ea        example:latest   /bin/bash           3 weeks ago         Up About a minute                       stupefied_pare      
    $ cat /etc/hosts.docker 
    # Docker hosts. This file is auto-generated by /home/jay/bin/rebuild_docker_hosts.py on each docker
    # invocation.
    #
    # Last updated: Sat Aug 30 18:41:23 2014 with 1 running containers

    172.17.0.4  example.com
    $ ping -c1 example.com
    PING example.com (172.17.0.4) 56(84) bytes of data.
    64 bytes from example.com (172.17.0.4): icmp_seq=1 ttl=64 time=0.085 ms

    --- example.com ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 0.085/0.085/0.085/0.000 ms

## Installation

There are few parts that need to be installed.

* copy `additional-dnsmasq.conf` to `/etc/NetworkManager/dnsmasq.d/docker`
* add the contents of docker-bashrc.sh to your `.bashrc`
* copy `rebuild_docker_hosts.py` to your `bin` (e.g. `$HOME/bin` or `/usr/local/bin`)
* enable your user to sudo to `nobody` without a password (I have a docker group, so I use `%docker ALL=(nobody) NOPASSWD: ALL`)
* create `/etc/hosts.docker` and ensure that it's writable by your user (e.g. `sudo chown root.docker /etc/hosts.docker && chmod 0775 /etc/hosts.docker`)
{'fraction_non_alphanumeric': 0.10039592760180996, 'fraction_numerical': 0.04355203619909502, 'mean_word_length': 2.5512048192771086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3412639', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1099, 'n_words': 389}