简体   繁体   English

Docker NPM 无法从 Github 获取私有模块/回购

[英]Docker NPM Cannot get private module / repo from Github

I try to build a docker image but I cannot pull the private module from Github.我尝试构建 docker 映像,但无法从 Github 中提取私有模块。 I am using https in my package.json but when doing docker build ssh is used, I don't know why... I am using https in my package.json but when doing docker build ssh is used, I don't know why...

"dependencies": {
    "my-pkg": "git+https://GITHUB_TOKEN:x-oauth-basic@github.com/myuser/my-pkg.git#tag
},

docker build errors docker 构建错误

#9 33.09 npm notice
#9 33.10 npm ERR! code 128
#9 33.10 npm ERR! command failed
#9 33.10 npm ERR! command git ls-remote ssh://git@github.com/myuser/my-pkg.git
#9 33.10 npm ERR! Host key verification failed.
#9 33.10 npm ERR! fatal: Could not read from remote repository.
#9 33.10 npm ERR!
#9 33.10 npm ERR! Please make sure you have the correct access rights
#9 33.10 npm ERR! and the repository exists.

I've tried including the git insteadOf in my Dockerfile我试过在我的 Dockerfile 中包含 git 而不是

RUN git config --global url."https://github.com/".insteadOf git@github.com:
RUN git config --global url."https://".insteadOf git://

But still, I didn't get it to work...但是,我仍然没有让它工作......

In your docker container you need to run ssh-keyscan and add it to ssh known hosts在您的 docker 容器中,您需要运行 ssh-keyscan 并将其添加到 ssh 已知主机

RUN touch /root/.ssh/known_hosts
RUN ssh-keyscan -H github.com > /root/.ssh/known_hosts

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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