Search code examples
linuxdockerkubernetesopenshift

download & install openshift cli command not working


I want to add the download and installation step of OpenShift CLI 4.6 on a docker file. I have added the following lines but it's not working.

RUN curl -L https://github.com/openshift/okd/releases/download/4.6.0-0.okd-2021-02-14-205305/openshift-client-linux-4.6.0-0.okd-2021-02-14-205305.tar.gz \
   | tar xz && install openshift-client-linux-4.6.0-0.okd-2021-02-14-205305.tar.gz /usr/bin/oc && rm -rf openshift*

But I am getting the following error

tar (child): openshift-client-linux-4.6.0-0.okd-2021-02-14-205305.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
% Total    % Received % Xferd  Average Speed   Time    Time     Time 

Current

curl: (23) Failed writing body (1354 != 1371)


Solution

  • curl -L https://github.com/openshift/okd/releases/download/4.6.0-0.okd-2021-02-14-205305/openshift-client-linux-4.6.0-0.okd-2021-02-14-205305.tar.gz | tar xz will extract the files in the tarball, so finally, the files in that folder would be next:

    $ ls
    kubectl  oc  README.md
    

    You could see no openshift-client-linux-4.6.0-0.okd-2021-02-14-205305.tar.gz there, if you really need it, you need do as next:

    curl -L https://github.com/openshift/okd/releases/download/4.6.0-0.okd-2021-02-14-205305/openshift-client-linux-4.6.0-0.okd-2021-02-14-205305.tar.gz -O to write it to folder.