TL;DR: Use dos2unix

While switching from Ubuntu to Alpine images, I've encountered the fillowing error:

standard_init_linux.go:195: exec user process caused "no such file or directory"

Quite unfortunate, because the script stayed in the same spot and only the image changed. After reading a bunch, I figured that it's the fact that I'm editing on Windows and Alpine doesn't seem to interpret #/bin/sh properly - adding a ^M :). The solution is to either fix the script locally or to format it as part of the docker build process. I chose the latter as the former depends on the developer.

Since dos2unix is not part of Alpine, one needs to install it. At the time of writing, the package is on the edge branch. Therefore, the install sequence would be:

RUN echo http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories
RUN echo http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories
RUN apk add --no-cache dos2unix

We copy the script and post-process it:

COPY ./docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh

RUN dos2unix /docker-entrypoint.sh

At this point, the script is primed for execution and the error is practically fixed.

Optimisation

In the quest to reduce the docker image, the actual sequence is:

COPY ./docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh

# Convert to unix the script
RUN echo http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && \
    echo http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories && \
    apk add --no-cache --virtual .build-deps dos2unix  && \
    dos2unix /docker-entrypoint.sh  && \
    apk del .build-deps  && \
    rm -rf /var/cache/apk/*

This will ensure dos2unix is removed at the end of processing.

HTH