Possible to connect to Docker network on build?

I’m trying to make a local nodejs development environment in docker, and an issue I’m trying to solve for is network connectivity. When npm installs happen, multiple network calls are made, even if it packages already exist. To solve this, I used a local npm cache (local-npm) in a docker container. I have port 5080 exposed on the localhost, so I can have a regular npm install on the host machine just look at the local registry at localhost:5080 and get the packages without hitting the network. However, when I’m trying to build a container, the only thing that works is if I call docker build --network=host from the command line, so in my docker file, I can set the registry to localhost:5080:

RUN npm config set registry http://localhost:5080

but this seems to be causing problems on my network (containers are getting disconnected, and resolves with me turning wifi on or off, or restarting the docker daemon)

so I tried:

RUN npm config set registry http://localnpm_net:5080

and ran:

docker build --no-cache -t experiment --network localnpm_net .

But it fails right away.