2017-08-25 109 views
0

我有一个dockerfile。其中我必须使用https url克隆bitbucket中的存储库,但我想如何传递密码以使克隆完成?是的,我试过SSH。它的作品,但我需要https克隆一些shell脚本运行,以便它应该自动接受密码。用https使用dockerfile克隆位桶回购。如何传递密码?

这里是我的泊坞窗命令克隆回购:

运行git克隆https://[email protected]/abc/xyz.git

这里是错误,我得到的同时buildind搬运工文件:\

克隆到“newfolder '... fatal:无法读取'https://[email protected]'的密码:没有此类设备或地址

我的构建命令是:

sudo docker build --no-cache = true -t image:build。

+1

的[有没有办法使用HTTPS时跳过密码打字?:在GitHub上//]可能的复制(https://stackoverflow.com/questions/5343068/is-there- https-on-github) – Ferrybig

回答

1

您可以在URL中指定的密码,例如:

git clone https://username:[email protected]/abc/xyz.git 

如果你不想硬编码在dockerfile密码,你可以把它作为构建ARG。

ARG password 
RUN git clone https://username:[email protected]/abc/xyz.git 

sudo docker build --build-arg password=pass --no-cache=true -t image:build .

+0

我试过了,但仍然出现以下错误: 克隆到“新文件夹”中... 致命:无法访问' https://用户名:@ password123 @ bitbucket.org/abc/xyz.git /':无法解析主机:[email protected] –

+0

您的密码以@开头。它被解释为主机。你需要通过%40转义@字符 – yamenk

+0

它的工作..谢谢。 –