title: pip install package from private github repo with deploy key in docker
body: <p>I'm trying to build a Docker container that should install a series of python packages from a requirements.txt file. <strong>One of the entries is a python package hosted on a private GitHub repository.</strong> To install it, I've created a pair of SSH keys and added the public one as a Deploy Key to the GitHub repository.</p>
  <p>However, when I'm building the container I'm getting this error:</p>
  <pre><code>ERROR: Command errored out with exit status 128: git clone -q 'ssh://****@github.com:organization/my-package' /tmp/pip-install-e81w4wri/my-package Check the logs for full command output.
  </code></pre>
  <p>I've tried to debug the error by changing the pip install command of the docker file with <code>RUN git clone git@github.com:organization/my-package.git</code> and it did work fine.</p>
  <p>What does this error mean and how can I solve it? I could clone it and install it with a dedicated command, but if possible I'd like to keep all requirements in a single place. Thanks!</p>
  <p>This is the Dockerfile that I'm using:</p>
  <pre><code>FROM joyzoursky/python-chromedriver:3.7-alpine3.8 as base
  
  FROM base as builder
  
  RUN echo &quot;http://dl-8.alpinelinux.org/alpine/edge/community&quot; &gt;&gt; /etc/apk/repositories
  RUN apk --no-cache --update-cache add bash gcc gfortran build-base git wget freetype-dev libpng-dev openblas-dev openssh-client
  RUN ln -s /usr/include/locale.h /usr/include/xlocale.h
  
  # copy requirements
  RUN mkdir /install
  WORKDIR /install
  COPY ./requirements.txt /var/www/requirements.txt
  
  ### GITHUB SSH KEY ###
  COPY ./keys/deploy_key_private .
  RUN mkdir /root/.ssh &amp;&amp; mv deploy_key_private /root/.ssh/id_rsa
  RUN eval $(ssh-agent) &amp;&amp; \
      ssh-add /root/.ssh/id_rsa &amp;&amp; \
      ssh-keyscan -H github.com &gt;&gt; /etc/ssh/ssh_known_hosts
  
  RUN pip install --upgrade pip &amp;&amp; pip install --prefix=/install -r /var/www/requirements.txt --log logs.txt
  
  FROM base
  COPY --from=builder /install /usr/local
  # KEEP ON BUILDING THE CONTAINER
  </code></pre>
  <p>The package is listed in the <code>requirements.txt</code> as <code>git+ssh://git@github.com:organization/my-package@master#egg=my_package</code></p>
  <p>If relevant, here is the traceback from pip:</p>
  <pre><code>Exception information:
  2020-07-30T11:56:55,329 Traceback (most recent call last):
  2020-07-30T11:56:55,329   File &quot;/usr/local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py&quot;, line 216, in _main
  2020-07-30T11:56:55,329     status = self.run(options, args)
  2020-07-30T11:56:55,329   File &quot;/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py&quot;, line 182, in wrapper
  2020-07-30T11:56:55,329     return func(self, options, args)
  2020-07-30T11:56:55,329   File &quot;/usr/local/lib/python3.7/site-packages/pip/_internal/commands/install.py&quot;, line 325, in run
  2020-07-30T11:56:55,329     reqs, check_supported_wheels=not options.target_dir
  2020-07-30T11:56:55,329   File &quot;/usr/local/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py&quot;, line 183, in resolve
  2020-07-30T11:56:55,329     discovered_reqs.extend(self._resolve_one(requirement_set, req))
  2020-07-30T11:56:55,329   File &quot;/usr/local/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py&quot;, line 388, in _resolve_one
  2020-07-30T11:56:55,329     abstract_dist = self._get_abstract_dist_for(req_to_install)
  2020-07-30T11:56:55,329   File &quot;/usr/local/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py&quot;, line 340, in _get_abstract_dist_for
  2020-07-30T11:56:55,329     abstract_dist = self.preparer.prepare_linked_requirement(req)
  2020-07-30T11:56:55,329   File &quot;/usr/local/lib/python3.7/site-packages/pip/_internal/operations/prepare.py&quot;, line 469, in prepare_linked_requirement
  2020-07-30T11:56:55,329     hashes=self._get_linked_req_hashes(req)
  2020-07-30T11:56:55,329   File &quot;/usr/local/lib/python3.7/site-packages/pip/_internal/operations/prepare.py&quot;, line 239, in unpack_url
  2020-07-30T11:56:55,329     unpack_vcs_link(link, location)
  2020-07-30T11:56:55,329   File &quot;/usr/local/lib/python3.7/site-packages/pip/_internal/operations/prepare.py&quot;, line 99, in unpack_vcs_link
  2020-07-30T11:56:55,329     vcs_backend.unpack(location, url=hide_url(link.url))
  2020-07-30T11:56:55,329   File &quot;/usr/local/lib/python3.7/site-packages/pip/_internal/vcs/versioncontrol.py&quot;, line 733, in unpack
  2020-07-30T11:56:55,329     self.obtain(location, url=url)
  2020-07-30T11:56:55,329   File &quot;/usr/local/lib/python3.7/site-packages/pip/_internal/vcs/versioncontrol.py&quot;, line 641, in obtain
  2020-07-30T11:56:55,329     self.fetch_new(dest, url, rev_options)
  2020-07-30T11:56:55,329   File &quot;/usr/local/lib/python3.7/site-packages/pip/_internal/vcs/git.py&quot;, line 230, in fetch_new
  2020-07-30T11:56:55,329     self.run_command(make_command('clone', '-q', url, dest))
  2020-07-30T11:56:55,329   File &quot;/usr/local/lib/python3.7/site-packages/pip/_internal/vcs/versioncontrol.py&quot;, line 774, in run_command
  2020-07-30T11:56:55,329     log_failed_cmd=log_failed_cmd)
  2020-07-30T11:56:55,329   File &quot;/usr/local/lib/python3.7/site-packages/pip/_internal/vcs/versioncontrol.py&quot;, line 166, in call_subprocess
  2020-07-30T11:56:55,329     raise SubProcessError(exc_msg)
  2020-07-30T11:56:55,329 pip._internal.exceptions.SubProcessError: Command errored out with exit status 128: git clone -q 'ssh://****@github.com:organization/my-package' /tmp/pip-install-e81w4wri/my-package Check the logs for full command output.
  </code></pre>