Search code examples
dockerdockerfilefedoraxargs

Fedora Docker image doesn't have xargs


I have the following Dockerfile:

FROM fedora:27

RUN xargs

When I run docker build -t test . I get the following output:

$ docker build -t test .
Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM fedora:27
 ---> 7a2e85963474
Step 2/2 : RUN xargs
 ---> Running in fbe9bfbedfe0
/bin/sh: xargs: command not found
The command '/bin/sh -c xargs' returned a non-zero code: 127

I expect Fedora to have xargs by default, but it does not appear to be available. What else should I try?


Solution

  • If you need xargs, then install xargs. Docker images are intentionally minimal; you are meant to customize them with the tools you need by using them as the base for building your own image.

    FROM fedora:27
    
    RUN yum -y install findutils
    RUN xargs
    

    If you're not sure which package provides a command you can also run yum -y install /usr/bin/xargs.