Search code examples
dockerdockerfiledocker-toolbox

Dockerfile's RUN command doesn't find script


Using Docker Toolbox on Windows 10, Docker cannot build an image from my Dockerfile because it doesn't find a script (install-composer) that was copied to the image.

FROM php:7.2.5-apache

COPY scripts/install-composer /usr/bin
RUN chmod +x /usr/bin/install-composer
RUN /usr/bin/install-composer

The error I get, when reating the last RUN command, is:

/bin/sh: 1: /usr/bin/install-composer: not found

The chmod command does work however, indicating the file does actually exist in the image.


Solution

  • A very simple problem but a very misleading error.

    The problem was caused by wrong file endings. Git was set up to convert the project files into Windows (CRLF) file endings. I reinstalled Git with the setting "Checkout as-is, commit Unix-style", deleted and recloned the repository, and it fixed the problem.

    When it comes to explaining the misleading and confusing error message, my guess is that the file install-composer was actually found and executed. What it is actually saying was that was not found. This empty name was simply the CR caught between two LF (in other words, an empty line) and sh interpreted it as a call to a script file.