tar command not found in Dockerfile

你。 提交于 2019-12-22 05:39:12

问题


I am trying to download a file in rhel6 and use tar to uncompress it. I am running this on docker. I get a wierd error saying /bin/sh: tar: command not found. I am new to linux and docker. Can someone help.

#HELLO
FROM rhel6
MAINTAINER xxxxx

#RUN yum -y install wget

RUN yum update -y && yum clean all

#RUN yum -y install tar

RUN curl -OL  http://username:pwd@downloads.datastax.com/enterprise/dse-4.0.3-bin.tar.gz

RUN curl -OL  http://username:pwd@downloads.datastax.com/enterprise/opscenter-4.0.3.tar.gz

RUN echo $PATH

RUN tar -xzvf opscenter-4.0.3.tar.gz

RUN rm *.tar.gz

回答1:


Very strange...this wasn't happening...then all of a sudden started happening. I'm not sure why, but I got around it by installing tar.x86_64:

FROM centos:6
RUN     yum -y update && \
    yum -y install wget && \
    yum install -y tar.x86_64 && \
    yum clean all



回答2:


I tried with a similar one, richxsl/rhel6.5 bash

$ docker run -it richxsl/rhel6.5 bash
[root@5f3b0b7539a3 /]# tar
bash: tar: command not found
[root@5f3b0b7539a3 /]# yum install tar
Loaded plugins: product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
No package tar available.
Error: Nothing to do
[root@5f3b0b7539a3 /]#

May be you need to register to Red Hat Subscription Management ?




回答3:


After a lot of pain i came to know that when you are inside a container it is not registered to RHN or satellite. I doubt if REDHAT provides this feature in the near future.

What i did is to get required rpm's from CENTOS and install them on top of RHEL6.

RUN curl -OL ftp://fr2.rpmfind.net/linux/centos/6.6/os/x86_64/Packages/unzip-6.0-1.el6.x86_64.rpm
RUN yum install -y unzip-6.0-1.el6.x86_64.rpm
RUN rm unzip-6.0-1.el6.x86_64.rpm

I think this is the best strategy for now. Take the very basic RHEL6 image and install required packages from CENTOS. You should be using this custom RHEL6 image for your development purposes.

https://access.redhat.com/articles/881893



来源:https://stackoverflow.com/questions/27613153/tar-command-not-found-in-dockerfile

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!