使用dockerfile克隆使用https的bit-bucket repo.如何传递密码?

tus*_*til 0 git github git-clone docker dockerfile

我有一个dockerfile.我必须使用https url从bitbucket克隆存储库,但我想如何传递密码以使克隆完成? 是的,我尝试了ssh.它工作,但我需要https克隆的一些shell脚本运行,以便它应自动接受密码.

这是我的docker命令克隆repo:

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

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

克隆到'newfolder'...致命:无法读取' https://username@bitbucket.org '的密码:没有这样的设备或地址

我的构建命令是:

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

yam*_*enk 7

您可以在URL中指定密码:

git clone https://username:password@bitbucket.org/abc/xyz.git
Run Code Online (Sandbox Code Playgroud)

如果您不想在dockerfile中对密码进行硬编码,则可以将其作为构建arg传递.

ARG password
RUN git clone https://username:$password@bitbucket.org/abc/xyz.git
Run Code Online (Sandbox Code Playgroud)

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