【问题标题】:Docker NPM Cannot get private module / repo from GithubDocker NPM 无法从 Github 获取私有模块/仓库
【发布时间】:2020-12-09 04:34:38
【问题描述】:

我尝试构建一个 docker 镜像,但我无法从 Github 中提取私有模块。我在 package.json 中使用 https,但是在使用 docker build ssh 时,我不知道为什么...

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

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.

我尝试在我的 Dockerfile 中包含 git insteadOf

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

但是,我还是没有让它工作......

【问题讨论】:

标签: node.js git docker github npm


【解决方案1】:

在您的 docker 容器中,您需要运行 ssh-keyscan 并将其添加到 ssh 已知主机

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-29
    • 2021-11-04
    • 2021-07-24
    • 1970-01-01
    • 2018-10-20
    • 2012-10-19
    • 2023-03-25
    相关资源
    最近更新 更多