SSH Support within docker build

Answered

Hi,

I'm trying to follow the https://blog.jetbrains.com/go/2020/05/04/go-development-with-docker-containers/ post but apply it to one of our own projects.

The build is failing because we use an internal repository to host our own packages and it requires SSH authentication.

I've done something similar with VSCode and that worked because it was able to use the ssh-agent on the Windows machine but I can't see any option to use that in GoLand, nor can I work out any way of injecting the keys into the container through the Dockerfile process.

Is this something that anyone has done and, if so, can they point me in the right direction?

Cheers

Gareth

4 comments
Comment actions Permalink

How are you building the container?

Normally, Docker supports passing the SSH agent socket or keys to it when running the build command, like this:

docker build --ssh default=c:/users/<user>/.ssh/id_rsa .
0
Comment actions Permalink

I'm using the Dockerfile configuration inside of GoLand

I've tried putting --ssh into the Build options field but I get a warning: "Can't parse CLI options: Unrecognized option: --ssh"

I also tried passing a build-arg through which works in git-bash: --build-arg "ssh_prv_key=$(cat ~/.ssh/id_rsa)" but in GoLand the cat command is not expanded out.

0
Comment actions Permalink

The `--ssh` option is not correctly identified by the plugin, I raised an issue for this on the tracker. This approach seems to be the one suggested for such cases, per this StackOverflow response. However, it seems it has its problems too.

How are you configuring this from VSCode? Is it using the `--ssh` option or something else?

0
Comment actions Permalink

Hi Florin,

Thanks for raising that.

In VSCode we use the Visual Studio Code Remote - Containers plugin (https://code.visualstudio.com/docs/remote/containers) which automatically uses the ssh-agent on the host if there's one running.

0

Please sign in to leave a comment.