tushar patil
tushar patil

Reputation: 369

Cloning bit-bucket repo with https using dockerfile.How to pass a password?

I have a dockerfile. In which i have to clone a repository from bitbucket using https url but how am i suppose to pass a password to make the clone complete? And yes i tried ssh .it works but i need https clone for some shell script to run so that it should automatically accepts the password.

Here is my docker command to clone repo:

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

And here is the error i get while buildind docker file : \

Cloning into 'newfolder'... fatal: could not read Password for 'https://[email protected]': No such device or address

MY build command is :

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

Upvotes: 0

Views: 4678

Answers (1)

yamenk
yamenk

Reputation: 51836

You can specify the password in the url as such:

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

If you don't want to hardcode the password in the dockerfile, you can pass it as a build 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 .

Upvotes: 7

Related Questions