[Solved]-Getting flake8 returned a non none zero code : 1 in docker


It might be a good idea to only let the code linting happen within your Django App folder. So if you followed the tutorial without alterations, you may want to replace this line:

RUN flake8 --ignore=E501,F401 .

with your Django project code…

RUN flake8 --ignore=E501,F401 ./hello_django

Otherwise, there’s probably a lot of stuff that gets checked by flake8 that you don’t want checked.


flake8 is a library to check errors in code and make sure there is no undefined variables or imports that are not being used.

The reason you are getting the errors are listed within the error itself. However, it seems that flake8 is scanning the virtual environment (env folder) and listing all the errors. To solve this problem you either want to point it to the subdirectory that has your python code (created by you). Or add ignore statement / file to ignore env folder.

having that said, for your use case chaining the code to be:

RUN flake8 --ignore=E501,F401 ./hello_django 

will solve your problem



I had the same problem and user13641454s solution worked great. If you are still getting the same error I suggest you run flake8 from the terminal to see the actual errors:

install flake8
flake8 --ignore=E501,F401 ./hello_django

It’s likely something trivial like an extra line or something in your code.



I also got the same problem, as shown below and how solved is that, by fixing the error as mentioned their in error " settings.py:23:1: E265 block comment should start with ‘# ‘. "

Edit the comment line give the proper space like ‘# This is comment’

you may got different type but fix it by as per error suggestions.

Leave a comment