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.

  • Flask API breaks at long Cypher query
  • org.apache.spark.SparkException: Job aborted due to stage failure with Yarn and Docker
  • Why does docker crash on high memory usage?
  • Can't start application within docker using linked mysql database
  • Using a local network Docker registry server
  • Kubernetes Docker AUFS DIFF directory growing
  • Docker machine instructions guided me to create an entry in my /etc/hosts file: 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 is docker better if tools like fedora's devassistant and virtualenv exist? [closed]
  • curl_slist_free_all() causes segfault on GKE w/ Debian 8.7
  • How to access a Tensorflow docker instance from the “outside” without Jupyter - for distributed Tensorflow
  • Forced logout when i run a docker container
  • Docker connection issue - connection timeout
  • Dokku Buil Failed - Pre-receive hook declined
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.