Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Não estou conseguindo criar o container com o docker ERROR [web 5/5] RUN pip install requirements.txt

root@serverpantoja-300E4M-300E4S-300E4L:/home/server/Cursos/typescript/restaurantes_api-master# docker compose build [+] Building 19.7s (9/9) FINISHED docker:default => [web internal] load build definition from Dockerfile 0.3s => => transferring dockerfile: 202B 0.0s => [web internal] load .dockerignore 0.2s => => transferring context: 2B 0.0s => [web internal] load metadata for docker.io/library/python:3 2.7s => [web 1/5] FROM docker.io/library/python:3@sha256:1615c71b5f3d48844b8d20cac4838f34267d96c3b061dcb6e4fda61a71599a9d 0.0s => [web internal] load build context 0.5s => => transferring context: 3.23kB 0.0s => CACHED [web 2/5] RUN mkdir /app 0.0s => CACHED [web 3/5] WORKDIR /app 0.0s => [web 4/5] ADD . /app/ 1.5s => ERROR [web 5/5] RUN pip install -r requirements.txt 13.4s

[web 5/5] RUN pip install -r requirements.txt: 4.524 WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fd3e4e23bf0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/asgiref/ 5.026 WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fd3e50e0440>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/asgiref/ 6.028 WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fd3e4c11040>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/asgiref/ 8.030 WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fd3e4c11520>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/asgiref/ 12.03 WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fd3e4c11790>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/asgiref/ 12.05 ERROR: Could not find a version that satisfies the requirement asgiref==3.4.1 (from versions: none) 12.05 ERROR: No matching distribution found for asgiref==3.4.1


failed to solve: process "/bin/sh -c pip install -r requirements.txt" did not complete successfully: exit code: 1

Quando tento dar o build retorna esse erro acima, não estou conseguindo criar as imagens e subir os container. :(

1 resposta
solução!

Fala galerinha, tenho um certo conhecimento em docker, então, consegui efetuar a correção do bug. Vou estar deixando o que eu fiz aqui para ajudar quem também estiver com problemas para "buildar" e executar o container. Primeiramente você pode deixar o 'DockerFile' assim

Troque a versão do python para 3.9.0 e também retire a linha

RUN pip install -r requirements.txt

Ficando assim o arquivo.

FROM python:3.9.0
ENV PYTHONUNBUFFERED 1
RUN mkdir /app
WORKDIR /app
ADD . /app/
 

Após isso, você pode estar se direcionando ao arquivo 'docker-compose.yml' e alterando a chave de command para a seguinte

      command: bash -c "pip install -r requirements.txt && python manage.py makemigrations && python manage.py migrate && python manage.py loaddata seed.json && python manage.py runserver 0.0.0.0:8000"

ou seja o arquivo ficará assim

version: '3.8'
services:
   web:
      build: .
      command: bash -c "pip install -r requirements.txt && python manage.py makemigrations && python manage.py migrate && python manage.py loaddata seed.json && python manage.py runserver 0.0.0.0:8000"
      volumes:
      - .:/app
      ports:
          - 8000:8000

O que fiz aqui foi apenas colocar o comando de execução do requirements direto na criação do container, e também alterei a versão do python. Tentei apenas alterar a versão e não funcionou, então fiz o comando em tempo de criação, e funcionou beleza. hehehe espero ajudar.

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software