Skip to content

Simple bash command fails during build #618

@neon12345

Description

@neon12345

Due to a failed build I have stripped down a simple Dockerfile that should run an ls command on a bash shell to list some directories, but instead fails. I tried to alter the RUN command but nothing seems to help.

The Dockerfile contains:

FROM debian:stable

RUN ["/bin/bash", "-c", "ls -d /usr/bin/[a-Z]*"]

I run a debian stable clean install with:

ii  docker-ce                             5:18.09.3~3-0~debian-stretch      amd64        Docker: the open-source application container engine
ii  docker-ce-cli                         5:18.09.3~3-0~debian-stretch      amd64        Docker CLI: the open-source application container engine

Doing a build will have the unexpected result:

Sending build context to Docker daemon  8.704kB
Step 1/2 : FROM debian:stable
 ---> c04b519eaefa
Step 2/2 : RUN ["/bin/bash", "-c", "ls -d /usr/bin/[a-Z]*"]
 ---> Running in 4629f06f6b47
ls: cannot access '/usr/bin/[a-Z]*': No such file or directory
The command '/bin/bash -c ls -d /usr/bin/[a-Z]*' returned a non-zero code: 2

Also manually running the command on a normal shell works with:

/bin/bash -c "ls -d /usr/bin/[a-Z]*"

and fails as expected with:

/bin/sh -c "ls -d /usr/bin/[a-Z]*"

Thanks,

Alex

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions