Issue with adding Python to custom Docker image

I am using a Raspberry Pi with n8n in a Docker container.

I followed this comment by Jan

This is what the Dockerfile looks like:

FROM n8nio/n8n
RUN apk add --update python3 py3-pip
RUN python3 -m pip install requests
RUN python3 -m pip install --upgrade pip

This is what the terminal and error looks like after running docker build -t n8n-python .

[email protected]:~/docker/n8n $ docker build -t n8n-python .
Sending build context to Docker daemon  2.048kB
Step 1/4 : FROM n8nio/n8n
 ---> 334e3849c8ec
Step 2/4 : RUN apk add --update python3 py3-pip
 ---> Running in be1bab2f27da
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/armv7/APKINDEX.tar.gz
3069625232:error:0D0D90AD:asn1 encoding routines:ASN1_TIME_adj:error getting time:crypto/asn1/a_time.c:330:
3069625232:error:0D0D90AD:asn1 encoding routines:ASN1_TIME_adj:error getting time:crypto/asn1/a_time.c:330:
3069625232:error:0D0D90AD:asn1 encoding routines:ASN1_TIME_adj:error getting time:crypto/asn1/a_time.c:330:
3069625232:error:0D0D90AD:asn1 encoding routines:ASN1_TIME_adj:error getting time:crypto/asn1/a_time.c:330:
3069625232:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:ssl/statem/statem_clnt.c:1914:
ERROR: https://dl-cdn.alpinelinux.org/alpine/v3.15/main: Permission denied
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.15/main: No such file or directory
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/armv7/APKINDEX.tar.gz
ERROR: https://dl-cdn.alpinelinux.org/alpine/v3.15/community: temporary error (try again later)
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.15/community: No such file or directory
ERROR: unable to select packages:
  py3-pip (no such package):
    required by: world[py3-pip]
  python3 (no such package):
    required by: world[python3]
The command '/bin/sh -c apk add --update python3 py3-pip' returned a non-zero code: 2

I also have a reverse proxy called Nginx Proxy Manager, could this be interfering with Docker?

Hey @d4vidsha, at first glance this looks like a problem with the Alpine repository:

ERROR: https://dl-cdn.alpinelinux.org/alpine/v3.15/main: Permission denied

I’ll give this a go on my end (once I have found an unused Raspi to play with) and will get back to you shortly.

So I quickly gave this a go and the docker build command finished as expected:

Output
[email protected]:~/n8n-python$ docker build -t n8n-python .
Sending build context to Docker daemon  2.048kB
Step 1/4 : FROM n8nio/n8n
 ---> 9da9bd45e3e9
Step 2/4 : RUN apk add --update python3 py3-pip
 ---> Running in 1a33d6d74764
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/aarch64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/aarch64/APKINDEX.tar.gz
(1/7) Installing libffi (3.2.1-r6)
(2/7) Installing gdbm (1.13-r1)
(3/7) Installing ncurses-terminfo-base (6.1_p20200118-r4)
(4/7) Installing ncurses-libs (6.1_p20200118-r4)
(5/7) Installing readline (8.0.1-r0)
(6/7) Installing sqlite-libs (3.30.1-r2)
(7/7) Installing python3 (3.8.10-r0)
Executing busybox-1.31.1-r9.trigger
OK: 104 MiB in 44 packages
Removing intermediate container 1a33d6d74764
 ---> 026aae4095c8
Step 3/4 : RUN python3 -m pip install requests
 ---> Running in 4541de98075f
Collecting requests
  Downloading requests-2.27.1-py2.py3-none-any.whl (63 kB)
Collecting idna<4,>=2.5
  Downloading idna-3.3-py3-none-any.whl (61 kB)
Collecting certifi>=2017.4.17
  Downloading certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.8-py2.py3-none-any.whl (138 kB)
Collecting charset-normalizer~=2.0.0
  Downloading charset_normalizer-2.0.12-py3-none-any.whl (39 kB)
Installing collected packages: urllib3, idna, charset-normalizer, certifi, requests
Successfully installed certifi-2021.10.8 charset-normalizer-2.0.12 idna-3.3 requests-2.27.1 urllib3-1.26.8
WARNING: Running pip as root will break packages and permissions. You should install packages reliably by using venv: https://pip.pypa.io/warnings/venv
WARNING: You are using pip version 21.1.1; however, version 22.0.4 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
Removing intermediate container 4541de98075f
 ---> 9e30ba676437
Step 4/4 : RUN python3 -m pip install --upgrade pip
 ---> Running in e1057477e9c7
Requirement already satisfied: pip in /usr/lib/python3.8/site-packages (21.1.1)
Collecting pip
  Downloading pip-22.0.4-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 21.1.1
    Uninstalling pip-21.1.1:
      Successfully uninstalled pip-21.1.1
Successfully installed pip-22.0.4
WARNING: Running pip as root will break packages and permissions. You should install packages reliably by using venv: https://pip.pypa.io/warnings/venv
Removing intermediate container e1057477e9c7
 ---> fa34438fea8b
Successfully built fa34438fea8b
Successfully tagged n8n-python:latest

Seeing the part that fails seems to be the 3069625232:error:0D0D90AD:asn1 encoding routines:ASN1_TIME_adj:error getting time:crypto/asn1/a_time.c:330:, are you perhaps using a 32 bit CPU or OS? You’d be affected by this problem then:

Unfortunately, this isn’t something the Alpine team can fix from the sounds of it:

I suppose there is nothing we can fix in the alpine image, so I close this issue.

Perhaps you can consider switching to a 64 bit OS?

Very strange. It should actually be possible. Our n8n default image is Alpine based, also installs Python, and gets also built for “linux/arm/v7”, which if I understand it correctly is 32bit.

You can find the code here:

Interesting, I ran uname -m in the terminal which gave me armv7l which is a 32 bit OS. I believe RPi 4 is able to run 64 bit OS so I’ll try it out. Any specific operating system you would recommend?

Additionally, the last time I built n8n-python successfully was about 3 weeks ago.

Turns out, all that I needed to do was the following two commands:

wget http://ftp.us.debian.org/debian/pool/main/libs/libseccomp/libseccomp2_2.5.3-2_armhf.deb

sudo dpkg -i libseccomp2_2.5.3-2_armhf.deb

Everything works now, no operating system changes needed.

Edit: source of commands

3 Likes

Very nice, thanks so much for confirming!