Skip to content

Repository files navigation

buildkit-ssh-sample

Sample Docker "hello-world" with Go + Github. Demonstrates a build using Docker Buildkit with SSH agent forwarding.

Overview

This Docker image builds a small Go binary that imports a public example Go module from Github. Some Go/git trickery is employed to force the build to download the example module from Github via SSH. This emulates the use-case where a Go module is hosted in a private Github repo and downloaded via SSH at build-time.

Docker buildkit's --ssh option is used to pass the hosts's SSH agent into the Docker build. Because the public Go module is downloaded via SSH, the host SSH agent must be configured with a valid Github user's SSH keypair.

Usage

Linux

  • Install Docker Engine Docker Install Docs
  • Set up your Github SSH keys and add them to your SSH agent Github Docs
  • Clone this repository locally and open a terminal to the cloned files location
  • Run the build script ./build-and-run-linux.sh

Windows

As of Docker Desktop 2.4.0.0-stable with Docker engine 19.03.13, following these instructions will result in an error similar to the following:


could not parse ssh: [default]: failed to open \\.\\pipe\\openssh-ssh-agent: open \\.\\pipe\\openssh-ssh-agent: All pipe instances are busy.

  • Install Docker Desktop for Windows Docker Install Docs
  • Install the Windows OpenSSH agent Microsoft Docs
  • Ensure the "OpenSSH Authentication Agent" service is enabled and running
  • Add your Github SSH keys to the SSH agent Microsoft Docs
  • Clone this repository locally
  • Run the build script build-and-run-windows.bat

Other Notes

The Windows OpenSSH agent is hardcoded to listen on a named pipe at \\.\\pipe\\openssh-ssh-agent Microsoft code on Github

About

Example Docker build utilizing buildkit with ssh-agent forwarding. Built to demonstrate a bug in Windows 10 ssh-agent forwarding with Buildkit and Docker Desktop

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages