I use the --ssh
docker buildkit feature and it works fine locally.
I want to build Docker at a remote server and for that I use the -A
flag to forward my local github key, like:
ssh -i "server.pem" -A <user>@<server-ip>
Then in server terminal I run:
ssh -T git@github.com
And I get the "Hello user" message, which means the key forwarding works fine.
(In the server, $SSH_AUTH_SOCK
is indeed set, and I can git clone
)
Now, when building locally I use:
DOCKER_BUILDKIT=1 docker build --ssh default=~/.ssh/id_rsa -t myimage:latest .
Which works fine.
But in the server the private key does not exists at ~/.ssh/id_rsa. So how can I forward it to docker build?
Tried this in the server:
DOCKER_BUILDKIT=1 docker build --ssh default=$SSH_AUTH_SOCK -t myimage:latest .
But it does not work. The error is:
could not parse ssh: [default]: invalid empty ssh agent socket, make sure SSH_AUTH_SOCK is set
Even though SSH_AUTH_SOCK
is set
Docker version: 19.03