Mac OSX Docker Desktop alpine container cannot communicate with particular host

I experience strange behaviour on Mac OSX Docker Desktop when I start a container and try to access a service say at http://repository.test.example.com/repository.

So I start alpine docker run -it alpine and run command curl http://repository.test.example.com/repository However same service running on another environment
http://repository.stage.example.com/repository works.

Verified:

  1. Remote service is running. Using curl on Mac shell works
  2. Started a Ubuntu VM install docker and checked it works on there too
  3. Colleague did not have the same issue

So the issue seems to be related to when container started in Mac OSX directly particularly my Mac.

Commands

docker run -it alpine
apk add curl
curl http://repository.test.example.com/repository
# Does not receive content just hangs until timeout

Solution

Realised it has to be something to do with my Docker Desktop. I re-installed but no luck. However I saw my settings for Docker desktop doesn’t change. So I needed to remove user settings for Docker Desktop in order to fix it.

Identified any preference files in following folders

  • ls -l /Users/username/Library/ApplicationSupport | grep -i docker (removing this had no -impact)
  • ls -l /Users/username/Library/Preferences | grep -i docker (removing this had no impact)
  • ls -l /Users/username/Library/Containers/ | grep -i docker
  • ls -l /Users/username/Library/Group Containers/ | grep -i docker

and remove any files and folder. This cleared all the user specific settings and Docker Desktop started fresh. Then the issue is solved as well.

If you need to remove any user settings for application, check and remove relevant files and folders from above directories.

Another useful post Where do OSX applications typically store user configuration data?

Source: StackOverflow