# Issue with adding Python to custom Docker image

**URL:** <https://community.n8n.io/t/issue-with-adding-python-to-custom-docker-image/12008>\
**Category:** Questions\
**Tags:** deployment\
**Created:** [March 9, 2022, 3:37am UTC](https://community.n8n.io/t/issue-with-adding-python-to-custom-docker-image/12008 "2022-03-09T03:37:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![d4vidsha](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/d4vidsha/32/24617_2.png) [@d4vidsha](https://community.n8n.io/u/d4vidsha)\
**Post date:** [March 9, 2022, 3:37am UTC](https://community.n8n.io/t/issue-with-adding-python-to-custom-docker-image/12008/1 "2022-03-09T03:37:38Z")

</div>

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

I followed [this comment](http://community.n8n.io/t/running-python-with-n8n/5715/3) by Jan

This is what the `Dockerfile` looks like:

```auto
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 .`

```auto
pi@raspberrypi:~/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?

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [March 9, 2022, 10:17am UTC](https://community.n8n.io/t/issue-with-adding-python-to-custom-docker-image/12008/2 "2022-03-09T10:17:41Z")

</div>

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

> ERROR: [https://dl-cdn.alpinelinux.org/alpine/v3.15/main:](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.

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [March 9, 2022, 10:36am UTC](https://community.n8n.io/t/issue-with-adding-python-to-custom-docker-image/12008/3 "2022-03-09T10:36:31Z")

</div>

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

> **Output**
>
> ```auto
> tom@ember:~/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:

> <https://github.com/alpinelinux/docker-alpine/issues/110>
>
> armv7:
> \`\`\`
> docker run --rm -it alpine@sha256:9dcd267f53cb0afee197077bb1c8e2ec7…f01d5340c33f7eb6c6ee1031813e721 \\
> apk add -vv --no-cache curl
> 
> fetch https://dl-cdn.alpinelinux.org/alpine/edge/main/armv7/APKINDEX.tar.gz
> WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/edge/main/armv7/APKINDEX.tar.gz: temporary error (try again later)
> fetch https://dl-cdn.alpinelinux.org/alpine/edge/community/armv7/APKINDEX.tar.gz
> 3070120864:error:0D0D90AD:asn1 encoding routines:ASN1\_TIME\_adj:error getting time:crypto/asn1/a\_time.c:330:
> 3070120864:error:0D0D90AD:asn1 encoding routines:ASN1\_TIME\_adj:error getting time:crypto/asn1/a\_time.c:330:
> 3070120864:error:0D0D90AD:asn1 encoding routines:ASN1\_TIME\_adj:error getting time:crypto/asn1/a\_time.c:330:
> 3070120864:error:0D0D90AD:asn1 encoding routines:ASN1\_TIME\_adj:error getting time:crypto/asn1/a\_time.c:330:
> 3070120864:error:1416F086:SSL routines:tls\_process\_server\_certificate:certificate verify failed:ssl/statem/statem\_clnt.c:1913:
> WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/edge/community/armv7/APKINDEX.tar.gz: Permission denied
> ERROR: unsatisfiable constraints:
> curl (missing):
> required by: world\[curl\]
> \`\`\`
> 
> Same for armv6/armhf:
> \`\`\`
> docker run --rm -it alpine@sha256:b0729a3bebc8b269c81293eb8eb261db69f0f16d59439ababf13165dff1b4881 \\
> apk add -vv --no-cache curl
> 
> fetch https://dl-cdn.alpinelinux.org/alpine/edge/main/armhf/APKINDEX.tar.gz
> WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/edge/main/armhf/APKINDEX.tar.gz: temporary error (try again later)
> fetch https://dl-cdn.alpinelinux.org/alpine/edge/community/armhf/APKINDEX.tar.gz
> 3070026656:error:0D0D90AD:asn1 encoding routines:ASN1\_TIME\_adj:error getting time:crypto/asn1/a\_time.c:330:
> 
> \[snip\]
> \`\`\`
> ... I had to run it twice to get an error message.

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?

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [March 9, 2022, 11:02am UTC](https://community.n8n.io/t/issue-with-adding-python-to-custom-docker-image/12008/4 "2022-03-09T11:02:37Z")

</div>

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:

> <https://github.com/n8n-io/n8n/blob/master/docker/images/n8n/Dockerfile>

---

<div class="post-metadata">

**Author:** ![d4vidsha](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/d4vidsha/32/24617_2.png) [@d4vidsha](https://community.n8n.io/u/d4vidsha)\
**Post date:** [March 9, 2022, 8:43pm UTC](https://community.n8n.io/t/issue-with-adding-python-to-custom-docker-image/12008/5 "2022-03-09T20:43:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![d4vidsha](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/d4vidsha/32/24617_2.png) [@d4vidsha](https://community.n8n.io/u/d4vidsha)\
**Post date:** [March 10, 2022, 2:26am UTC](https://community.n8n.io/t/issue-with-adding-python-to-custom-docker-image/12008/6 "2022-03-10T02:26:29Z")

</div>

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](https://www.reddit.com/r/docker/comments/t33ci5/cant_figure_out_libseccomp/)

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [March 10, 2022, 7:08am UTC](https://community.n8n.io/t/issue-with-adding-python-to-custom-docker-image/12008/7 "2022-03-10T07:08:00Z")

</div>

Very nice, thanks so much for confirming!
