从私有gilab存储库中提取的Docker容器

我正在为我的Node.js + Vue应用程序构build一个Docker容器。

由于我在另一个仓库中有一个全局的css库,我在我的package.json文件中添加了这一行:

"lib-css": "git+ssh://git@git.lib.com:9922/username/lib-css.git#development", 

这样,当我运行npm install我也安装我的CSS库。 问题是在我的本地env它要求我的密码,我可以插入它,但在Docker生成过程失败,出现以下错误:

 Step 7/10 : RUN npm install ---> Running in db10ca83586d npm WARN deprecated babel-preset-es2015@6.24.1: 🙌 Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update! npm ERR! Error while executing: npm ERR! /usr/bin/git ls-remote -h -t ssh://git@git.lib.com:9922/username/lib-css.git npm ERR! npm ERR! Host key verification failed. npm ERR! fatal: Could not read from remote repository. npm ERR! npm ERR! Please make sure you have the correct access rights npm ERR! and the repository exists. npm ERR! npm ERR! exited with error code: 128 npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2017-12-11T08_49_11_152Z-debug.log 

这是我目前的Dockerfile

 FROM node:carbon WORKDIR /usr/src/app RUN mkdir -p /root/.ssh COPY .secrets /root/.ssh/id_rsa RUN chmod 700 /root/.ssh && chmod 600 /root/.ssh/* # Install app dependencies # A wildcard is used to ensure both package.json AND package-lock.json are copied # where available (npm@5+) COPY package*.json ./ RUN npm install # If you are building your code for production # RUN npm install --only=production # Bundle app source COPY . . EXPOSE 8081 CMD [ "npm", "run dev" ] ~ 

我的.secrets文件包含与存储库关联的我的私钥。

我怎样才能做到这一点?