简体   繁体   English

在Dockerfile中找不到tar命令

[英]tar command not found in Dockerfile

I am trying to download a file in rhel6 and use tar to uncompress it. 我试图在rhel6中下载文件并使用tar解压缩它。 I am running this on docker. 我在码头上运行这个。 I get a wierd error saying /bin/sh: tar: command not found. 我得到一个奇怪的错误说/ bin / sh:tar:命令未找到。 I am new to linux and docker. 我是linux和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

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: 我不知道为什么,但我通过安装tar.x86_64解决了这个问题:

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

I tried with a similar one, richxsl/rhel6.5 bash 我尝试过类似的一个,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 ? 您可能需要注册Red Hat Subscription Management吗?

After a lot of pain i came to know that when you are inside a container it is not registered to RHN or satellite. 经过很多痛苦后我才知道,当你在一个容器内时,它没有注册到RHN或卫星。 I doubt if REDHAT provides this feature in the near future. 我怀疑REDHAT是否会在不久的将来提供此功能。

What i did is to get required rpm's from CENTOS and install them on top of RHEL6. 我所做的是从CENTOS获得所需的rpm并将它们安装在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. 获取最基本的RHEL6映像并从CENTOS安装所需的软件包。 You should be using this custom RHEL6 image for your development purposes. 您应该使用此自定义RHEL6映像进行开发。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM