How to add credentials to Docker ADD command

2019-08-26 08:29发布

I have this:

ADD https://bitbucket.org/teros/vana/raw/"$commit"/mw/requirements.txt  'requirements.txt'

but the HTTP request won't work since I need creds. I do know that this curl command works:

bitbucket_curl(){
   curl -H 'Authorization:Basic YW1bGx..plM2JyKg==' "https://api.bitbucket.org$@"
}

(token was modified, but the command is o/w right)

So maybe there's a token I can included as a url parameter with Bitbucket?

1条回答
神经病院院长
2楼-- · 2019-08-26 09:24

Should just be as simple as:

ARG bitbucket_pwd
ARG commit

ADD "https://user@domain.com:$bitbucket_pwd@bitbucket.org/teros/vana/raw/$commit/mw/requirements.txt"  '/temp/requirements.txt'

you can pass the ARGs in using --build-arg

docker build --build-arg bitbucket_pwd="$bitbucket_password"
查看更多
登录 后发表回答