在docker中安装npm会导致github拒绝连接

我正在尝试创build一个Dockerfile,以便在Codeship Pro上执行我的testing。 dockerfile应该安装nvm,node和npm,然后执行npm install。 这工作正常第一次(即销毁从我的本地docker工人的所有图像后),但然后它产生这个错误(系统,只有在提供与github链接而不是包名称的依赖)

这可能与npmcaching有关,因为当我在npm安装之前添加下面的行时,错误消失了(但是我想每次都不重build所有东西?):

RUN npm cache clean 

错误日志:

 npm ERR! (image: xxx) (service: app) (image: xxx) (service: app) node v4.8.4 (image: xxx) (service: app) npm ERR! (image: xxx) (service: app) npm (image: xxx) (service: app) v3.7.3 (image: xxx) (service: app) npm ERR! (image: xxx) (service: app) code (image: xxx) (service: app) 128 (image: xxx) (service: app) (image: xxx) (service: app) npm ERR! Command failed: git clone --template=/root/.npm/_git-remotes/_templates --mirror https://github.com/philippeauriach/sitemap-stream.git /root/.npm/_git-remotes/git-https-github-com-philippeauriach-sitemap-stream-git-cfb2fa17abb1819df77726b5db155ab53cee7a65-98e098ac (image: xxx) (service: app) npm ERR! (image: xxx) (service: app) Cloning into bare repository '/root/.npm/_git-remotes/git-https-github-com-philippeauriach-sitemap-stream-git-cfb2fa17abb1819df77726b5db155ab53cee7a65-98e098ac'... npm (image: xxx) (service: app) (image: xxx) (service: app) ERR! fatal: unable to access 'https://github.com/philippeauriach/sitemap-stream.git/': Failed to connect to github.com port 443: Connection refused 

Dockerfile:

 FROM ubuntu:16.04 ENV NVM_DIR /usr/local/nvm ENV NODE_VERSION 4.8.4 RUN curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash # install node and npm RUN source $NVM_DIR/nvm.sh \ && nvm install $NODE_VERSION \ && nvm alias default $NODE_VERSION \ && nvm use default \ && npm install npm@3.7.3 -g ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH RUN mkdir /usr/src/app WORKDIR /usr/src/app COPY . ./ RUN npm install --unsafe-perm #unsafe perm because node is launched as "root" by docker