简体   繁体   中英

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?

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 (ie 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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