2020-09-27

How do I replace "\r" line endings when running Docker script on Windows?

I'm using Docker 19 on Windows 10 (using Cygwin to run Docker). I have this web/Dockerfile ...

FROM python:3.7-slim

RUN apt-get update && apt-get install

RUN apt-get install -y dos2unix
RUN apt-get install -y libmariadb-dev-compat libmariadb-dev
RUN apt-get update \
    && apt-get install -y --no-install-recommends gcc \
    && rm -rf /var/lib/apt/lists/*

RUN python -m pip install --upgrade pip

WORKDIR /app/

COPY requirements.txt requirements.txt

COPY entrypoint.sh entrypoint.sh

RUN tr -d '\r' < /app/entrypoint.sh > /app/entrypoint2.sh
RUN python -m pip install -r requirements.txt

RUN grep '\r' /app/entrypoint.sh
RUN dos2unix /app/entrypoint.sh
RUN grep '\r' /app/entrypoint.sh

ENTRYPOINT ["bash", "/app/entrypoint.sh"]

and the entrypoint.sh file referenced looks like

#!/bin/bash
set -e

python manage.py migrate
python manage.py migrate directory
python manage.py docker_init_db_data

exec "$@"

But I guess there are some "\r" line endings that causes running "docker-compose up" on Windows to die. In my above file, I have

RUN dos2unix /app/entrypoint.sh

But I guess this doesn't do it, because running "docker-compose up" results in

web_1     | set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
web_1     | /app/entrypoint.sh: line 3: $'\r': command not found
web_1     | Unknown command: 'migrate\r'. Did you mean migrate?
web_1     | Type 'manage.py help' for usage.

How do I properly replace "\r" line endings in my shell script so that I can properly run my Dockerfile on Windows (and ideally all other) platforms?



from Recent Questions - Stack Overflow https://ift.tt/3cBkBFR
https://ift.tt/eA8V8J

No comments:

Post a Comment