Docker Community Forums

Share and learn in the Docker community.

[Networking issue] Cannot ping remote server from within Docker container

Hello, everyone,

I’m reaching you as last resort with an issue that I am trying to fix for the last 2 days. I covered all the similar issues from Stackoverflow and this forum that I could find, but was still not able to solve my issue.

[PROBLEM]

  • I have a remote server with an SQL Server instance that I can reach using a VPN
  • I can ping it with no problems from my local machine
  • As soon as I enter my Docker container I cannot ping it anymore, with the ping error message “Destination Host Unreachable”
  • Since I cannot even ping it, I am not able to access the SQL Server database within the server
  • I am not an IT guy so my knowledge of Networking and related deep stuff is very short

[MORE INFORMATION]

  • I can ping successfully the VPN root server within the container.
  • I can ping successfully other web servers with the container, such as the IP 8.8.8.8.
  • I can ping the server within the WSL.
  • I’m running my Docker container using docker-compose and already added “network_mode:host”, with no success
  • I also tried an example docker image from a colleague who was able to ping the remote server and I could not ping it as well, what suggests me that the problem might be some local setting that I am missing

I am running the following Docker version:
Client: Docker Engine - Community
Cloud integration: 1.0.4
Version: 20.10.0
API version: 1.41
Go version: go1.13.15
Git commit: 7287ab3
Built: Tue Dec 8 18:55:31 2020
OS/Arch: windows/amd64
Context: default
Experimental: true

Server: Docker Engine - Community
Engine:
Version: 20.10.0
API version: 1.41 (minimum version 1.12)
Go version: go1.13.15
Git commit: eeddea2
Built: Tue Dec 8 18:58:04 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.4.3
GitCommit: 269548fa27e0089a8b8278fc4fc781d7f65a939b
runc:
Version: 1.0.0-rc92
GitCommit: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
docker-init:
Version: 0.19.0
GitCommit: de40ad0

It may be a very obvious thing I am missing, since I am new to Docker.

Thank you very much in advance and hope you can help me.

Best regards

Solved the problem.

The problem was related with the default subnet of Docker, that intercepted the subnet that I was trying to reach.

The first default subnet of docker is: 172.18.0.0/16

You can change it by editing the daemon.json that you can find in the directory “Users\username.docker\daemon.json” and adding the parameter:
“default-address-pools” : [
{
“base” : “172.31.0.0/16”,
“size” : 24
}