I'm working to launch a django-tornado hybrid app in a Docker container from a shell script and and getting --noinput
as an unrecognized argument for django commands:
usage: manage.py collectstatic [-h] [--version] [-v {0,1,2,3}]
[--settings SETTINGS] [--pythonpath PYTHONPATH]
[--traceback] [--no-color] [--noinput]
[--no-post-process] [-i PATTERN] [-n] [-c] [-l]
[--no-default-ignore]
manage.py collectstatic: error: unrecognized arguments: --noinput
Why would I be getting --noinput
as an unrecognized argument? My Dockerfile calls a deployment shell script which performs the collectstatic
and migrate
commands (both with the --noinput
argument, which is failing for both. I've played around with removing extraneous lines, adjusting whitespace around the command, etc, to no avail. I can run the shell script locally without any issues; it seems to only be a problem in the Docker container RUN
call to the shell script.
Dockerfile:
FROM python:2.7
RUN apt-get update
RUN apt-get install -y build-essential
RUN apt-get install -y python-dev
RUN apt-get install -y libmysqlclient-dev
RUN mkdir /code
ADD . /code/
WORKDIR /code
RUN pip install -r requirements.txt
CMD ["sh","./deploy.sh"]
EXPOSE 8888
deploy.sh:
#!/bin/sh
python manage.py collectstatic --noinput
python manage.py migrate --noinput
python main.py
If I run the django commands in the Dockerfile with RUN python manage.py collectstatic --noinput
there is no issue, but I'm trying to get the application-specific commands in the CMD
call, since I need to have database environment vars from Elastic Beanstalk for my deployment environment.
Looks like my issue was line endings in the shell script. I think sh was feeding in --noinput\R
into python, so it was presenting itself in the terminal as looking like --noinput
, but really it was getting a CR
character as well that it was matching against.
When I was locally testing, it was in the Docker Quickstart terminal (where it worked), and the Docker containers were always running in Ubuntu (where it was failing).
I've hit this way in the past before where different line endings in shell scripts that were written on Windows messed things up in a Linux environment, and I need to remember how important it is to set up line endings correctly in my editors...
I Solve this problem using notepad++
In your notepad++
Do Inspection
View > Show Symbol > Show All Characters
Look for CR LF line endings, rather than LF line endings!
Solving
Search > Replace (Ctrl+H)
Make sure Search Mode is set to Extended
Find \r\n and replace with \n
main problem in this case is there are CR aka carriage return in your sh file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With