Docker Desktop Windows and VPN is faling to get npm packages

I am trying to run a docker compose file but I am receiving an error: npm ERR! request to http://npm.mydns.com:1555/@tmypackage-0.14.0.tgz failed, reason: connect EHOSTUNREACH 199.99.900.140:1555

However, it is working when I request from Postman, Browser, telnet the only requirement is ensure my company VPN is connected.

Looks like during code compilation in order to create the image, it is not considering retrieve npm packages using VPN. I am not sure how to ensure Docker for windows is using VPN connection.

It should use the default route of your host.
You can easily check it by using curl to access a page in your intranet.

I have a hunch: can you check the subnet wsl uses, and the routes that your vpn injects into your route table?

You can identify the wsl subnet in a Windows terminal, using the command ipconfig. The entry is called “Ethernet-Adapter vEthernet (WSL (Hyper-V firewall))”. It should tell you the first ip in the subnet and the netmask. You can enter these values in a subnet calculator like IP Subnet Calculator. For example my ipv4 address for this adapter is 172.30.80.1, and the netmask 255.255.240.0 (=20 bit netmask), which has a range from 172.30.80.1 - 172.30.95.254.

You can see the route table in a Windows terminal, using the command route print -4. Network targets that intersect with the ranges of the wsl subnet, but are routed through the vpn will cause problem.

You need to make sure both ranges do not intersect. I found a forum post that describes how to change the ip of the wsl2 network. Make sure to save the old settings sometwhere in case it doesn’t work.

I was able to change wsl2 network ip and subnet, however, it have not work yet.

My route table

Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0    192.168.1.254     192.168.1.68     35
         10.0.0.0        255.0.0.0      10.40.200.1    10.40.201.145      2
       10.40.60.5  255.255.255.255      10.40.200.1    10.40.201.145      2
       10.40.60.6  255.255.255.255      10.40.200.1    10.40.201.145      2
      10.40.200.0    255.255.252.0         On-link     10.40.201.145    257
    10.40.201.145  255.255.255.255         On-link     10.40.201.145    257
    10.40.203.255  255.255.255.255         On-link     10.40.201.145    257
      80.85.99.66  255.255.255.255    192.168.1.254     192.168.1.68     36
    93.158.66.128  255.255.255.224      10.40.200.1    10.40.201.145      2
        100.0.0.0        255.0.0.0         On-link         100.0.0.1   5256
        100.0.0.1  255.255.255.255         On-link         100.0.0.1   5256
       100.64.0.0      255.192.0.0      10.40.200.1    10.40.201.145      2
  100.255.255.255  255.255.255.255         On-link         100.0.0.1   5256
     104.22.66.77  255.255.255.255      10.40.200.1    10.40.201.145      2
     104.22.67.77  255.255.255.255      10.40.200.1    10.40.201.145      2
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    331
        127.0.0.1  255.255.255.255         On-link         127.0.0.1    331
  127.255.255.255  255.255.255.255         On-link         127.0.0.1    331
       172.17.0.0      255.255.0.0      10.40.200.1    10.40.201.145      2
      172.18.36.0    255.255.255.0      10.40.200.1    10.40.201.145      2
       172.21.0.0    255.255.255.0      10.40.200.1    10.40.201.145      2
     172.21.100.0    255.255.255.0      10.40.200.1    10.40.201.145      2
      172.23.64.0    255.255.240.0         On-link       172.23.64.1   5256
      172.23.64.1  255.255.255.255         On-link       172.23.64.1   5256
    172.23.79.255  255.255.255.255         On-link       172.23.64.1   5256
    172.67.36.158  255.255.255.255      10.40.200.1    10.40.201.145      2
      192.168.1.0    255.255.255.0         On-link      192.168.1.68    291
     192.168.1.68  255.255.255.255         On-link      192.168.1.68    291
    192.168.1.254  255.255.255.255         On-link      192.168.1.68     36
    192.168.1.255  255.255.255.255         On-link      192.168.1.68    291
        224.0.0.0        240.0.0.0         On-link         127.0.0.1    331
        224.0.0.0        240.0.0.0         On-link      192.168.1.68    291
        224.0.0.0        240.0.0.0         On-link       172.23.64.1   5256
        224.0.0.0        240.0.0.0         On-link     10.40.201.145  10000
        224.0.0.0        240.0.0.0         On-link         100.0.0.1   5256
  255.255.255.255  255.255.255.255         On-link         127.0.0.1    331
  255.255.255.255  255.255.255.255         On-link      192.168.1.68    291
  255.255.255.255  255.255.255.255         On-link       172.23.64.1   5256
  255.255.255.255  255.255.255.255         On-link     10.40.201.145  10000
  255.255.255.255  255.255.255.255         On-link         100.0.0.1   5256

and also my new wsl2 details

Ethernet adapter vEthernet (WSL):

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::dd12:ad7f:602d:438b%53
   IPv4 Address. . . . . . . . . . . : 100.0.0.1
   Subnet Mask . . . . . . . . . . . : 255.0.0.0
   Default Gateway . . . . . . . . . :

Please make sure to use a subnet for the WSL network that is not publicly routed range:

  • 10.0.0.0/8: range 10.0.0.0 – 10.255.255.255
  • 172.16.0.0/12: range: 172.16.0.0 – 172.31.255.255
  • 192.168.0.0/16 range: 192.168.0.0 – 192.168.255.255

You used 8 bits for the netmask, which translates to an ip range with 16777216 ips. The 20 bits netmask that was configured by default had 4096 ips in the range. So please pick subnet within one of these ranges that is colision free with the subnets of your routing table,and collision free with docker’s subnets ranges.

You might want to get in touch with your company’s it support and ask them for assistance. If the problem is related to your vpn, then it’s high likely you are not the only one affected, so that they already know what configuration works collision free.