- In your Docker Engine configuration, make sure you have
experimentalset totrue&feature.buildkitset totrue
- In your
sshconfig, enablessh-agentforwarding viaForwardAgent yes - Make sure your
ssh-agentis running and your private key(s) have been added (quick setup guide)
If you want to make things easier on yourself, you can use keychain to manage your ssh key(s).
- Run
ssh-add -l. First make sure your key(s) are being loaded (if not, repeat step 3 carefully). Next make sure at least one of the valid indentities matches a valid ssh key linked to your GitHub account. Navigate to SSH and GPG keys in your user settings to see all of your active SSH keys.
- Add the following to any build steps that require your
sshpermissions:
services:
...
foo:
build:
...
ssh: [default]- For
alpineimages, add the following to yourDockerfile:
RUN apk add --update openssh git
RUN echo -e "PermitRootLogin yes" >> /etc/ssh/sshd_config
RUN mkdir -p /root/.ssh \
&& touch /root/.ssh/known_hosts
RUN ssh-keyscan github.com >> /root/.ssh/known_hosts- For any commands that require
sshpermissions, use the following prefix:
RUN --mount=type=ssh ...References:
