Juan049
Juan049

Reputation: 33

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?

Upvotes: 0

Views: 1501

Answers (2)

Stephen Fewings
Stephen Fewings

Reputation: 11

You need to specify the docker image tag approriate for the Rasp pi OS. I received this error and changed

FROM arm32v7/python:3.6-buster

to resove the error. You can find the best tag based on the OS version you are running. Find this out with

cat /etc/os-release

Upvotes: 1

Gereon Wolf
Gereon Wolf

Reputation: 1

As the error states you should propably add a link to your local timezone like this

RUN ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime

it helped me with my settup a few weeks ago In my case Europe/Berlin is correct. But you can use yours or the UTC +0 as you whish.

Upvotes: 0

Related Questions