1

I'm trying to dockerize a Vue SPA, but when I get to the below step during docker build .

# install simple http server for serving static content
RUN npm install -g http-server

I get the following after a few seconds:

Step 2/9 : RUN npm install -g http-server
---> Running in e30d7aa11a71
npm ERR! code EAI_AGAIN
npm ERR! errno EAI_AGAIN
npm ERR! request to https://registry.npmjs.org/http-server 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/2021-01-27T18_15_59_366Z-debug.log

I'm using the default Dockerfile from https://v2.vuejs.org/v2/cookbook/dockerize-vuejs-app.html so I expected it to just work out of the box

tony19
  • 125,647
  • 18
  • 229
  • 307
  • This question is a NPM-specific version of https://stackoverflow.com/questions/23810845/i-cant-get-docker-containers-to-access-the-internet, so if my solution doesn't work for you try the answers from there –  Sep 05 '21 at 09:20

1 Answers1

6

Building the image using docker run build . --network=host fixed the issue for me.

The error I was getting was caused by Docker not being able to access the Internet, so spoonfeeding it "hey, just use host" seems to have fixed the problem.

  • 11
    It's ... kind of surreal googling an error, opening a stackoverflow answer and finding out that both the question and the answer are mine but several months later –  May 24 '21 at 09:24