0

I know questions with such an error have already been asked several times, however I couldn't find a solution so I'm assuming that my case is different.

I have a Dockerfile like this:

FROM alpine:latest as builder

RUN apk add --no-cache bash

COPY bin /main/bin
COPY conf /main/conf

RUN ./main/bin/my-script 1

FROM mysql:5.7

COPY --from=builder /main/dist/sql /sql

ADD generate-databases.sh /docker-entrypoint-initdb.d

and this is working absolutely fine both on Linux, and on macOS(using Docker Desktop).

The problem is that on Windows using Docker Desktop I get the following error:

Service 'db' failed to build: The command '/bin/sh -c ./main/bin/my-script 1' returned a non-zero code: 127

why does this happen only on Windows, while working fine in other platforms?

Francesco Borzi
  • 56,083
  • 47
  • 179
  • 252

1 Answers1

1

The problem was actually not strictly related with Docker but with the line-ending format of my bash scripts, which on Windows were CRLF by default while they should have been LF.

To solve the issue I forced LF format in my .gitattributes.

Francesco Borzi
  • 56,083
  • 47
  • 179
  • 252