0
################################################################################
# Ubuntu 22.10
FROM ubuntu:22.10
################################################################################
# Install packages
RUN apt-get update && apt-get install --yes --no-install-recommends \
  build-essential \
  gfortran \
  meson \
  pkg-config \
  sox \
  git \
  cmake \
  openssh-client \
  python3 \
  python3-pip \
  python3-numpy 
################################################################################
# Create a Jenkins user with proper host group id and user id
ARG UNAME=jenkins
# Get group and user ids from outside "docker build" command line
ARG GID=
ARG UID=
RUN groupadd --gid $GID $UNAME && \
    useradd --gid $GID --uid $UID --home-dir /home/$UNAME --create-home $UNAME
################################################################################
# Add github.com to the list of known ssh hosts for user Jenkins
USER $UNAME
RUN mkdir /home/$UNAME/.ssh/ && \
    touch /home/$UNAME/.ssh/known_hosts && \
    ssh-keyscan github.com >> /home/$UNAME/.ssh/known_hosts
################################################################################
# Install myproj from myrepos:
RUN pip3 install --upgrade --user git+ssh://[email protected]/myrepos/myproj@master
################################################################################

I've created the above Dockerfile used by Jenkins automation server. The Dockerfile contains some fiddling with SSH keys to enable jenkins user to access my Git repositories. This enabled jenkins to run meson build system commands (and meson needs access to GitHub). All worked OK.

But now I needed to install a package from my GitHub repo which I usually install like this:

pip3 install --upgrade --user git+ssh://[email protected]/myrepos/myproj@master

However, when docker is run, I get error on the last RUN line:

[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

How would I access the repo from Dockerfile?

1 Answer 1

1

Your github repo is added to known hosts, but what about your repo key? How will the image you build via this Dockerfile know what that is?

Hypothetically you could COPY the key into the image so it has access and can pull from the private repo, but this isn't secure. You would additionally be adding more private credentials (from your github repo) to the image if you do this.

I would clone the repo locally and COPY the required files in, or mount as a volume.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.