用https使用dockerfile克隆位桶回购。如何传递密码?

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

这是我的docker命令来克隆repo:

运行git克隆https://username@bitbucket.org/abc/xyz.git

这里是我在buildind docker文件时得到的错误:\

克隆到“新文件夹”…致命:无法读取“ https://username@bitbucket.org ”的密码:没有这样的设备或地址

我的build立命令是:

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

您可以在url中指定密码,如下所示:

git clone https://username:password@bitbucket.org/abc/xyz.git 

如果您不想在dockerfile中对密码进行硬编码,则可以将其作为构buildparameter passing。

 ARG password RUN git clone https://username:$password@bitbucket.org/abc/xyz.git 

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