Zama Ques
Zama Ques

Reputation: 1534

Docker build failing with command not found

My Dockerfile is as follows:

  FROM registry.access.redhat.com/rhel6.7
  USER root
  MAINTAINER zaman L
  RUN mkdir /apps
  COPY httpd-2.4.34.tar.bz2 /tmp
  RUN /usr/bin/tar xjvf /tmp/httpd-2.4.34.tar.bz2 -C /apps
  VOLUME /tmp
  VOLUME /apps

But docker build is failing with this error:

  `Step 7 : RUN /usr/bin/tar xjvf /tmp/httpd-2.4.34.tar.bz2 -C /apps
   ---> Running in 541bdd63aac6
  /bin/sh: /usr/bin/tar: No such file or directory
  The command '/bin/sh -c /usr/bin/tar xjvf /tmp/httpd-2.4.34.tar.bz2 -C /apps' returned a non-zero code: 127`

How can I fix this?

Upvotes: 1

Views: 3959

Answers (1)

Claire Nielsen
Claire Nielsen

Reputation: 2161

It's failing because it can't find your tar executable in /usr/bin/tar.

A couple things you can do:

  • Replace /usr/bin/tar with tar, as mentioned in a comment.
  • Run which tar to see where your tar executable lives, and replace /usr/bin/tar with the output from that command.

Either of those should work - the first is more general (i.e. won't break if your tar executable ends up somewhere different later on), but the second won't start using a different executable if a tar is found earlier in your PATH search.

Upvotes: 1

Related Questions