I have a shell script that contains git clone command. This shell script is running in a docker container. How to write the Dockerfile so that git clone command can be run successfully. My current version as below:
RUN apk update; \
apk upgrade; \
apk add --no-cache \
git \
openssh \
openssh-client \
bash \
ca-certificates \
;
RUN --mount=type=ssh set -e -x; \
mkdir -p -m 0777 ~/.ssh; \
printf "Host github.com\n User git" > ~/.ssh/config; \
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts; \
git config --global url."git@github.com:".insteadOf "https://github.com/"; \
echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config;
And I got the following error:
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.