Docker fails to initialize after updating to Windows 10 insider build 14342

Problem:

Docker for windows hates windows insider, it attempts to create a switch that already exists (DockerNAT) and then fails because it already exists.

Solution:

There are a few suggestions here but the one that worked for me was to open hyper v manager, then go to virtual switch manager, and rename the existing ‘DockerNAT’ switch to something else, then reinstall Docker.

Docker 404 during apt get update

Problem:

During build of ubuntu images, apt-get can’t resolve any archives (404’s or ‘Cannot initiate the connection’).

Solution:

The issue is caused by the docker bridge hanging, so try the following:
sudo apt-get install bridge-utils
pkill docker
iptables -t nat -F
ifconfig docker0 down
brctl delbr docker0
sudo service docker restart

Openresty/NGINX accessing Docker environment variables

Problem:

Docker supports passing in environment variables to your containers as a handy way to easily switch environments when using multiple docker-compose files. For example you may have a base docker-compose.yml with a docker-compose.dev.yml and docker-compose.prod.yml file that specify environment variables for database hostnames/credentials.
The issue is simply accessing these environment variables directly isn’t possible in openresty (e.g. using os.getenv()).

Solution:

The issue is caused by NGINX blocking all environment variables by default. To make them accessible again you need to re-define them in your nginx.conf, but with no values, e.g:

env APP_ENV;

You should then be able to access them as normal.

NGINX DNS in docker

Problem:

Docker runs its own container DNS that means you can easily link containers together just by specifying their names, instead of having to work out their dynamically assigned IP’s somehow. Unfortunately NGINX doesn’t read the /etc/hosts file that docker edits, and so can’t resolve hostnames of other containers.

Solution:

An earlier hacky solution was to bundle dnsmasq in with nginx and have it use 127.0.0.1 as a resolver, violating the one process per container best practice.

As of Docker 1.10 you can use the new embedded DNS feature by setting 127.0.0.11 as the resolver in nginx.conf, just be aware that there are issues with IPv6.