简体   繁体   中英

Gitlab error message: remote: HTTP Basic: Access denied fatal: Authentication failed when running npm install on docker-compose build

I got an error message when running sudo docker-compose build

inside my Dockerfile, it was running:

RUN npm install

The error message says:

npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t https://git.mycompany.com/path_public/speakeasy.git
npm ERR! 
npm ERR! remote: HTTP Basic: Access denied
npm ERR! fatal: Authentication failed for 'https://git.mycompany.com/path_public/speakeasy.git/'
npm ERR! 
npm ERR! exited with error code: 128

I don't understand why running npm install requires git credentials.

I have tried to copy my local git credential to the docker container with docker cp but it doesn't work.

This error occurs because you are trying to install a library from your private registry but you have not logged in.

1. let your git repo remember your login: (15 mins)

run git config --global credential.helper cache

2. copy and paste the command it shows above, in your case:

/usr/bin/git ls-remote -h -t https://git.mycompany.com/path_public/speakeasy.git

This will ask you for credentials. If you are using 2-factor-authentication, you have to put in your username and accesstoken , otherwise put in your password .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM