Why this Docker setup fails to build my Clojure `tools-deps` project with dependencies on private Git repository? [on hold]

I’ve set up my Linux machine to build my Clojure project that depends on a private Git repository as described here. I can build my project locally.

I have tried to recreate the setup in Dockerfile:

FROM clojure:tools-deps-alpine
RUN apk add --no-cache openssh-client

# Authorize SSH Host
RUN mkdir -p /root/.ssh && 
    chmod 0700 /root/.ssh && 
    ssh-keyscan gitlab.com >> /root/.ssh/known_hosts && 
    ssh-keyscan bitbucket.com >> /root/.ssh/known_hosts && 
    ssh-keyscan github.com >> /root/.ssh/known_hosts

ARG ssh_prv_key
ARG ssh_pub_key

# Add the keys and set permissions
RUN echo "$ssh_prv_key" > /root/.ssh/id_rsa && 
    echo "$ssh_pub_key" > /root/.ssh/id_rsa.pub && 
    chmod 600 /root/.ssh/id_rsa && 
    chmod 600 /root/.ssh/id_rsa.pub

But when I try to build the same project inside a Docker container by running

clojure -A:uberjar

I get the following exception:

Cloning: [email protected]:my/repo.git
Error building classpath. connector is not available: 
com.jcraft.jsch.agentproxy.AgentProxyException: connector is not available: 
        at com.jcraft.jsch.agentproxy.ConnectorFactory.createConnector(ConnectorFactory.java:120)
        at clojure.tools.gitlibs.impl$fn__858.invokeStatic(impl.clj:30)
        at clojure.tools.gitlibs.impl$fn__858.invoke(impl.clj:28)
        at clojure.lang.Delay.deref(Delay.java:42)
        at clojure.core$deref.invokeStatic(core.clj:2320)
        at clojure.core$deref.invoke(core.clj:2306)
        at clojure.tools.gitlibs.impl$call_with_auth.invokeStatic(impl.clj:49)
        at clojure.tools.gitlibs.impl$call_with_auth.invoke(impl.clj:41)
        at clojure.tools.gitlibs.impl$git_clone_bare.invokeStatic(impl.clj:71)
        at clojure.tools.gitlibs.impl$git_clone_bare.invoke(impl.clj:68)
        at clojure.tools.gitlibs.impl$ensure_git_dir.invokeStatic(impl.clj:110)
        at clojure.tools.gitlibs.impl$ensure_git_dir.invoke(impl.clj:100)
        at clojure.tools.gitlibs$resolve.invokeStatic(gitlibs.clj:33)
        at clojure.tools.gitlibs$resolve.invoke(gitlibs.clj:29)
        at clojure.tools.gitlibs$procure.invokeStatic(gitlibs.clj:47)
        at clojure.tools.gitlibs$procure.invoke(gitlibs.clj:41)
        at clojure.tools.deps.alpha.extensions.git$eval925$fn__927.invoke(git.clj:41)
        at clojure.lang.MultiFn.invoke(MultiFn.java:239)
        at clojure.tools.deps.alpha$expand_deps.invokeStatic(alpha.clj:189)
        at clojure.tools.deps.alpha$expand_deps.invoke(alpha.clj:172)
        at clojure.tools.deps.alpha$resolve_deps.invokeStatic(alpha.clj:239)
        at clojure.tools.deps.alpha$resolve_deps.invoke(alpha.clj:221)
        at clojure.tools.deps.alpha.script.make_classpath$create_classpath.invokeStatic(make_classpath.clj:59)
        at clojure.tools.deps.alpha.script.make_classpath$create_classpath.invoke(make_classpath.clj:52)
        at clojure.tools.deps.alpha.script.make_classpath$run.invokeStatic(make_classpath.clj:70)
        at clojure.tools.deps.alpha.script.make_classpath$run.invoke(make_classpath.clj:64)
        at clojure.tools.deps.alpha.script.make_classpath$_main.invokeStatic(make_classpath.clj:109)
        at clojure.tools.deps.alpha.script.make_classpath$_main.doInvoke(make_classpath.clj:84)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.lang.Var.applyTo(Var.java:705)
        at clojure.core$apply.invokeStatic(core.clj:665)
        at clojure.main$main_opt.invokeStatic(main.clj:491)
        at clojure.main$main_opt.invoke(main.clj:487)
        at clojure.main$main.invokeStatic(main.clj:598)
        at clojure.main$main.doInvoke(main.clj:561)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.lang.Var.applyTo(Var.java:705)
        at clojure.main.main(main.java:37)

Source: StackOverflow