Error at build docker image in Raspberry pi

I am trying to build a image in my RaspBerryPi 4 with raspbian.
I want to make a docker image that run a python Image:
my directory is:

analizador_doff
  | tarea_periodica.py
  | Dockerfile
  | requirements.txt

my dockerfile is:


# syntax=docker/dockerfile:1

FROM python:3.9

WORKDIR /analizador_dof

ENV PYTHONUNBUFFERED=1

COPY requirements.txt requirements.txt
USER root
RUN pip3 install --user -r requirements.txt

COPY . .
CMD [ "python3", "-m" , "tarea_periodica", "run", "--host=0.0.0.0"

I use this build comand:
sudo docker build /media/pi/NAS/analizador_dof -t analizador_dof

I get an error in the pip3 instalation:

Sending build context to Docker daemon   42.5kB
Step 1/8 : FROM python:3.9
 ---> 227d977a853c
Step 2/8 : WORKDIR /analizador_dof
 ---> Using cache
 ---> 29c01a80aa78
Step 3/8 : ENV PYTHONUNBUFFERED=1
 ---> Using cache
 ---> 0dcba8a92785
Step 4/8 : COPY requirements.txt requirements.txt
 ---> Using cache
 ---> 46d0efc74e7d
Step 5/8 : USER root
 ---> Running in d3415c85eff5
Removing intermediate container d3415c85eff5
 ---> ac077459a187
Step 6/8 : RUN pip3 install --user -r requirements.txt
 ---> Running in 9153fd8d92a4
Fatal Python error: init_interp_main: can't initialize time
Python runtime state: core initialized
PermissionError: [Errno 1] Operation not permitted

Current thread 0xb6f2c010 (most recent call first):
<no Python frame>
The command '/bin/sh -c pip3 install --user -r requirements.txt' returned a non-zero code: 1

I have try many things:
*Use –user
*Use USER root
*Change DNS
*Use docker compose and privileged: true

And much more.
¿is a problem related with Raspberry?
¿Can somebody help me?

Source: Python Questions

LEAVE A COMMENT