I want download a private repository from bitbucket, but get some error
fatal: could not read Username for 'https://bitbucket.org': terminal prompts disabled
here my dockerfile
FROM golang:1.17 as build
RUN apt update && apt upgrade -y &&
apt install -y git
make openssh-client
WORKDIR /src
COPY . .
RUN git config --global url."https://username:[email protected]".insteadOf "https://bitbucket.org"
RUN go mod tidy
RUN go build -o user-management
3
Answers
never do that, you need download the repo outside the
docker build
command, and useCOPY
to transfer these files into images, when buildI think it’s most clean to use an ssh key for that. You can actually tell docker to use the config from your local ssh agent. You need to enable buildkit for this. See the docs.
In your Dockerfile, you need to mount this on a specific run instruction:
That requires you adding the same ssh key to your private bitbucket repo, so that you can use it to download dependencies.
There are more ways to mount secrets for the lifetime of a run instruction. See the docs.
For me helped add "machine github.com login USERNAME password APIKEY
" to $HOME/.netrc
My Dockerfile:
Maybe it will help you.