Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

797
Visualizações
Getting flake8 returned a non none zero code : 1 in docker

I was following this article. https://testdriven.io/blog/dockerizing-django-with-postgres-gunicorn-and-nginx/#production-dockerfile

In the Production Dockerfile section, the Dockerfile.prod file has these lines.

# lint
RUN pip install --upgrade pip
RUN pip install flake8
COPY . /usr/src/app/
RUN flake8 --ignore=E501,F401 .

When I run the below command,

docker-compose -f docker-compose.prod.yml up -d --build

I'm getting the below error.

ERROR: Service 'web' failed to build: The command '/bin/sh -c flake8 --ignore=E501,F401' returned a non-zero code: 1

I'm not much aware of flake8, When I commented the 'RUN flake8 --ignore=E501,F401 .' line from the Dockerfile.prod file everything worked.

Can anyone please tell me why I'm facing this issue and tell me a fix instead of removing that line from the Dockerfile. I'm not much aware of flak8 and I'm quite new to Docker too and your help will be much appreciated :)

Thanks.

over 4 years ago · Santiago Trujillo
4 Respostas
Responde à pergunta

0

It might me a good idea to (at least for now) only let the code linting happen within you 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, that you don't want checked by flake8.

over 4 years ago · Santiago Trujillo Relatório

0

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.

over 4 years ago · Santiago Trujillo Relatório

0

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

over 4 years ago · Santiago Trujillo Relatório

0

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.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda