0

i have been following the examples here on trying to download a private package in github via the docker command. My problem is i need a private token to access git.

I tried the following in my DockerFile:

# syntax = docker/dockerfile:1.0-experimental
FROM python:3.9

# create a folder and cd into it
run mkdir temp_repo
run cd temp_repo

# set folder as current working directory
workdir /temp_repo

# move hello_world.py script from our local system to current workdir in docker
add hello_world.py .

# copy the requirements file from current system to docker directory
copy requirements.txt .
run pip install -r requirements.txt
copy . /temp_repo

RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
RUN --mount=type=ssh pip install git+ssh://git@github.com/phobos-capital/phobos-db.git

Then in my localmachine, i type the following:

export DOCKER_BUILDKIT=1
eval 'ssh-agent'
ssh-add ~/.ssh/id_rsa
docker build --ssh default=$SSH_AUTH_SOCK .

Error im receiving:

    ```=> ERROR [9/9] RUN --mount=type=ssh pip install git+ssh://git@github.com/phobos-capital/phobos-db.git                                                                                                                                                                                                                                     0.7s
------
 > [9/9] RUN --mount=type=ssh pip install git+ssh://git@github.com/phobos-capital/phobos-db.git:
#18 0.427 Collecting git+ssh://****@github.com/phobos-capital/phobos-db.git
#18 0.427   Cloning ssh://****@github.com/phobos-capital/phobos-db.git to /tmp/pip-req-build-sm0ipk4k
#18 0.431   Running command git clone --filter=blob:none --quiet 'ssh://****@github.com/phobos-capital/phobos-db.git' /tmp/pip-req-build-sm0ipk4k
#18 0.499   Warning: Permanently added the ECDSA host key for IP address '140.82.114.4' to the list of known hosts.
#18 0.584   git@github.com: Permission denied (publickey).
#18 0.584   fatal: Could not read from remote repository.
#18 0.584 
#18 0.584   Please make sure you have the correct access rights
#18 0.585   and the repository exists.
#18 0.588   error: subprocess-exited-with-error
#18 0.588   
#18 0.588   × git clone --filter=blob:none --quiet 'ssh://****@github.com/phobos-capital/phobos-db.git' /tmp/pip-req-build-sm0ipk4k did not run successfully.
#18 0.588   │ exit code: 128
#18 0.588   ╰─> See above for output.
#18 0.588   
#18 0.588   note: This error originates from a subprocess, and is likely not a problem with pip.
#18 0.589 error: subprocess-exited-with-error
#18 0.589 
#18 0.589 × git clone --filter=blob:none --quiet 'ssh://****@github.com/phobos-capital/phobos-db.git' /tmp/pip-req-build-sm0ipk4k did not run successfully.
#18 0.589 │ exit code: 128
#18 0.589 ╰─> See above for output.
#18 0.589 
#18 0.589 note: This error originates from a subprocess, and is likely not a problem with pip.
This works in my private machine: 

    pip install git+https://github.com/phobos-capital/phobos-db
turtle_in_mind
  • 986
  • 1
  • 18
  • 36
  • 1
    Your local command does not match your command in the dockerfile. You are using https locally, and in the dockerfile ssh. Looks like your ssh key is not accepted by git. Try doing it locally with ssh. – The Fool Mar 24 '22 at 16:52
  • oh i got the same error locally, can i pass an https inside docker? – turtle_in_mind Mar 24 '22 at 16:54
  • 1
    I think your idea, isn't bad. It's actually good practice. You should add your ssh key to your git account. If you have access to that private repo, you will be able to pull over ssh. Maybe make a dedicated key though. – The Fool Mar 24 '22 at 16:59
  • https://stackoverflow.com/search?q=git+Permission+denied+publickey – phd Mar 24 '22 at 17:42

0 Answers0