18.09+ we can use the following approach to use a forwarded ssh key when building an image:
# syntax=docker/dockerfile:experimental # example file FROM node:10.15.3-alpine RUN apk update && apk add openssh-client git # use the forwarded ssh key RUN --mount=type=ssh git clone <repo>
Then we would build the image like this:
DOCKER_BUILDKIT=1 docker build --ssh default .
I would like to use
docker-compose to achieve this, but it does not seem to work. There is no
--ssh flag for the docker-compose command and I can't see anything I can set in the
docker-compose.yml file to accomplish this.