tar command not found in Dockerfile

2019-05-10 17:39发布

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

3条回答
我只想做你的唯一
2楼-- · 2019-05-10 18:09

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
查看更多
叼着烟拽天下
3楼-- · 2019-05-10 18:20

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 ?

查看更多
爷的心禁止访问
4楼-- · 2019-05-10 18:22

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

查看更多
登录 后发表回答