docker.local hostname in /etc/hosts not resolving on OSX for docker machine (causing rspec tests to fail)

I had a bug today where my rspec tests ran fine, down to the last expectation, but then I still got a “database connection timeout error”.

This is running rails locally, connecting to a postgres instance inside of docker, using docker machine.

  • Dockerizing PostgreSQL - psql Connection refused
  • ADDing from the command line interface to a newly created container
  • NPM install in Vagrant shared folder leads to filesystem issues
  • disable interactive mode in docker
  • Running tests as usual against docker containers or dockerize tests?
  • Run a hadoop cluster on docker containers
  • Docker machine instructions guided me to create an entry in my /etc/hosts file:

    192.168.99.100 docker.local 
    

    This worked fine for the test itself, but then something (probably some cleanup step after the test suite – possibly from DatabaseCleaner?) still raised an error about timing out connecting to the database.

    After a lot of investigation, debugging, even deleting and recreating the docker machine default container, I finally narrowed it down to if I replace docker.local with the actual IP address in the database config – it passes.

    So bottom line – some cleanup process didn’t have access to the /etc/hosts defined docker.local hostname.

    This is on OSX El Capitan.

  • How to configure autoscaling on docker swarm?
  • How to access container's web application from host
  • Backup of Docker image
  • Docker - Containers being removed after build
  • How do I access Windows eventlog of a Docker container
  • .dockerignore mentioned files are not ignored
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.