在Dockerfile中找不到tar命令

时间:2014-12-23 02:09:17

标签: linux docker rhel6

我正在尝试在rhel6中下载文件并使用tar来解压缩它。 我在码头上运行这个。我得到一个奇怪的错误说/ bin / sh:tar:命令未找到。 我是linux和docker的新手。有人可以帮忙。

#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 个答案:

答案 0 :(得分:3)

非常奇怪......这并没有发生......然后突然间开始发生了。我不确定原因,但我通过安装tar.x86_64来解决这个问题:

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

答案 1 :(得分:2)

我试过类似的一个,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 /]#

您可能需要注册Red Hat Subscription Management吗?

答案 2 :(得分:0)

经过很多痛苦后我才知道,当你在一个容器内时,它没有注册到RHN或卫星。我怀疑REDHAT是否会在不久的将来提供此功能。

我所做的是从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

我认为这是目前最好的策略。获取最基本的RHEL6映像并从CENTOS安装所需的软件包。您应该使用此自定义RHEL6映像进行开发。

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