user892871
user892871

Reputation: 1025

tar command not found in Dockerfile

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:[email protected]/enterprise/dse-4.0.3-bin.tar.gz

RUN curl -OL  http://username:[email protected]/enterprise/opscenter-4.0.3.tar.gz

RUN echo $PATH

RUN tar -xzvf opscenter-4.0.3.tar.gz

RUN rm *.tar.gz

Upvotes: 11

Views: 46923

Answers (3)

user2915097
user2915097

Reputation: 32196

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 ?

Upvotes: 0

hba
hba

Reputation: 7800

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

Upvotes: 11

user892871
user892871

Reputation: 1025

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

Upvotes: 1

Related Questions