rancher-sandbox / rancher-desktop

Container Management and Kubernetes on the Desktop
https://rancherdesktop.io
Apache License 2.0
5.91k stars 280 forks source link

moby docker build throws network error #1573

Closed kitsunekyo closed 2 years ago

kitsunekyo commented 2 years ago

Actual Behavior

i have a pretty simple dockerized app, which i want to start via docker-compose since nerdctl is broken atm #1431 i'm using moby instead, and for running containers it works fine. port mappings etc are all ok.

but if i try to build the containers via docker-compose it seems like docker doesn't have any network connectivity. i was using docker deskop with the same setup before, and this worked fine.

Steps to Reproduce

my dockerfile, building a regular express app:

# ./server/dockerfile
FROM node:12-alpine
WORKDIR /usr/src/app

COPY . .
RUN npm install
RUN npm run build

EXPOSE 3001
CMD ["node", "dist/server.js"]

Result

output

docker-compose up -d
Building api
Step 1/7 : FROM node:12-alpine
 ---> 1b156b4c3ee8
Step 2/7 : WORKDIR /usr/src/app
 ---> Using cache
 ---> e8b9fac680fd
Step 3/7 : COPY . .
 ---> Using cache
 ---> 9227a7c6fc7e
Step 4/7 : RUN npm install
 ---> Running in 748fd6c141e8
npm WARN server@1.0.0 No repository field.

npm ERR! code EAI_AGAIN
npm ERR! errno EAI_AGAIN
npm ERR! request to https://registry.npmjs.org/ms/-/ms-2.1.2.tgz failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-02-11T10_57_23_529Z-debug.log
ERROR: Service 'api' failed to build: The command '/bin/sh -c npm install' returned a non-zero code: 1

Expected Behavior

successful build, and running npm install without connection issues

Additional Information

commands are run in wsl2 ubuntu. and output is the same if i run docker build server directly

Rancher Desktop Version

1.0.1

Rancher Desktop K8s Version

1.23.3

Which container runtime are you using?

moby (docker cli)

What operating system are you using?

Windows

Operating System / Build Version

Windows 10 Pro 21H1 19043.1526

What CPU architecture are you using?

x64

Linux only: what package format did you use to install Rancher Desktop?

No response

Windows User Only

no special network configuration or software

kitsunekyo commented 2 years ago

since its open source, you can actually try out the whole application for reproduction tests

https://github.com/kitsunekyo/ISP-SpeedTest-Logger

Elektronenvolt commented 2 years ago

@kitsunekyo - do you get a DNS resolution for registry.npmjs.org from the rancher-desktop WSL ?

wsl -d rancher-desktop ping registry.npmjs.org

kitsunekyo commented 2 years ago

yeah, dns resolution seems fine.

PS C:\Users\xxx> wsl -d rancher-desktop
/mnt/c/Users/xxx# ping registry.npmjs.org
PING registry.npmjs.org (104.16.16.35): 56 data bytes
64 bytes from 104.16.16.35: seq=0 ttl=55 time=27.619 ms
64 bytes from 104.16.16.35: seq=1 ttl=55 time=24.652 ms
^C
--- registry.npmjs.org ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 24.652/26.135/27.619 ms

@Elektronenvolt completely offtopic, because i cant help myself:
do we know eachother from working at a major sportsbetting brand?

adamkpickering commented 2 years ago

FWIW, I was able to run this fine once installing docker-compose on Pop OS. But that's an entirely different platform. @mook-as maybe you could take a look?

Elektronenvolt commented 2 years ago

@kitsunekyo offtopic: yes we do... Regarding docker-compose - you've installed it in the rancher-desktop WSL with something like sudo apt-get install docker-compose ?

kitsunekyo commented 2 years ago

small world. yes, regular install. i’ve also already tried upgrading and a reinstall of docker-compose in wsl.

one thought was that it could maybe have something to do with my previous install of docker desktop, prior to the SLA change, but thats just a guess.

kitsunekyo commented 2 years ago

i did a netsh winsock reset and a clean reboot. this seems to have resolved the issue. something probably knocked over my hyper-v network config or something. thanks for your help

Elektronenvolt commented 2 years ago

it's a small country.. 😁 We had issues with Windows Defender Firewall and WSL on some machines - root cause unknown. Domain joined / non-domain joined / Win 10, 11 / fresh installed - I don't see a pattern... I fix it by adding a FW rule https://github.com/microsoft/WSL/issues/5336#issuecomment-1027232333 Another option: https://github.com/microsoft/WSL/issues/4139#issuecomment-947577448 That's why I've asked you if DNS resolution works.