Unable to install package using docker : kpt not found or ambiguous repo/dir@version specify '.git' in argument

319 views Asked by At

I am using below script and it giving me an error #/bin/sh: 1: kpt: not found

FROM nginx    
RUN apt update
RUN apt -y install git
RUN apt -y install curl

# install kpt package
RUN mkdir -p ~/bin
RUN curl -L https://github.com/GoogleContainerTools/kpt/releases/download/v1.0.0-beta.1/kpt_linux_amd64 --output ~/bin/kpt && chmod u+x ~/bin/kpt
RUN export PATH=${HOME}/bin:${PATH}
RUN SRC_REPO=https://github.com/kubeflow/manifests
RUN kpt pkg get $SRC_REPO/[email protected] tf-training

But if I create the image using

FROM nginx
RUN apt update
RUN apt -y install git
RUN apt -y install curl

and perform

docker exec -it container_name bash

and manually do the task then I am able to install kpt package. Sharing below the screenshot of the process enter image description here

The error changes if I provide the full path to /bin/kpt Error: ambiguous repo/dir@version specify '.git' in argument

FROM nginx
RUN apt update
RUN apt -y install git
RUN apt -y install curl
RUN mkdir -p ~/bin
RUN curl -L https://github.com/GoogleContainerTools/kpt/releases/download/v1.0.0-beta.1/kpt_linux_amd64 --output ~/bin/kpt && chmod u+x ~/bin/kpt
RUN export PATH=${HOME}/bin:${PATH}
# Below line of code is to ensure that kpt is installed and working fine
RUN ~/bin/kpt pkg get https://github.com/ajinkya101/kpt-demo-repo.git/Packages/Nginx
RUN SRC_REPO=https://github.com/kubeflow/manifests
RUN ~/bin/kpt pkg get $SRC_REPO/[email protected] tf-training

What is happening when I am using docker and not able to install it?

1

There are 1 answers

0
VonC On BEST ANSWER

First, make sure SRC_REPO is declared as a Dockerfile environment variable

ENV SRC_REPO=https://github.com/kubeflow/manifests.git
^^^                                               ^^^^

And make sure the URL ends with .git.
As mentioned in kpt get:

In most cases the .git suffix should be specified to delimit the REPO_URI from the PKG_PATH, but this is not required for widely recognized repo prefixes.

Second, to be sure, specify the full path of kpt, without ~ or ${HOME}.

/root/bin/kpt

For testing, add a RUN id -a && pwd to be sure who and where you are when using the nginx image.