Skip to content

Instantly share code, notes, and snippets.

@JoshuaGross
Created November 17, 2016 23:31
Show Gist options
  • Save JoshuaGross/6bed8fc4996f6a1c802ce49872aef7d0 to your computer and use it in GitHub Desktop.
Save JoshuaGross/6bed8fc4996f6a1c802ce49872aef7d0 to your computer and use it in GitHub Desktop.
Having trouble with networking in a Docker container?

Recently I've experienced strange issues with networking inside of Docker containers - like being unable to ping google.com from inside a container, and all of the common suggestions around DNS resolution not helping.

It turns out that Docker will copy your computer's default DNS settings into a container. If you change your DNS settings at some point - either manually or because your machine accepts defaults from your router/provider - the settings inside your cached Docker layers may no longer match what's on your machine, and certain DNS resolutions will fail in unusual ways.

My fix: docker run -it {image} /bin/bash manually (for example, docker run -it python:2.7 bash) to find the root image that is unable to resolve the domain you're interested in, and then remove the culprit with docker rmi {hash}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment