Dockerfile compatibility with Raspberry Pi?

7/1/2019

I have built the image from the following Dockerfile in my Rpi Kubernetes cluster. However, I was getting status of CrashLoopBackOff for my Pods.

After a bit of search on the internet, I realized that the problem maybe is with the Dockerfile's compatibility with RPi. I get following error when I run docker logs CONTAINER_ID

standard_init_linux.go:190: exec user process caused "exec format error"

The Dockerfile:

FROM ubuntu:18.04

RUN apt-get update && apt-get install -y \
    git \
    software-properties-common \ 
    python3-pip git
RUN add-apt-repository universe \
    && apt-get update
RUN pip3 install tornado sqlalchemy construct==2.5.5-reupload
RUN git clone https://github.com/majadoon/empower-runtime.git
RUN cd empower-runtime \
    && mkdir deploy

EXPOSE 8000 4433

WORKDIR /empower-runtime

CMD ["./empower-runtime.py"]

Moreover, I get the following error on Rpi if I build the same image on Pi:

Sending build context to Docker daemon  210.9kB
Step 1/9 : FROM ubuntu:18.04
 ---> e37fc27e0a1c
Step 2/9 : RUN apt-get update && apt-get install -y     git     software-properties-common     python3-pip git
 ---> Running in 842028d7fb7c
Get:1 http://ports.ubuntu.com/ubuntu-ports bionic InRelease [242 kB]
Get:2 http://ports.ubuntu.com/ubuntu-ports bionic-updates InRelease [88.7 kB]
Get:3 http://ports.ubuntu.com/ubuntu-ports bionic-backports InRelease [74.6 kB]
Get:4 http://ports.ubuntu.com/ubuntu-ports bionic-security InRelease [88.7 kB]
Get:5 http://ports.ubuntu.com/ubuntu-ports bionic/main armhf Packages [1277 kB]
Get:6 http://ports.ubuntu.com/ubuntu-ports bionic/restricted armhf Packages [12.5 kB]
Get:7 http://ports.ubuntu.com/ubuntu-ports bionic/multiverse armhf Packages [157 kB]
Get:8 http://ports.ubuntu.com/ubuntu-ports bionic/universe armhf Packages [11.0 MB]
Err:8 http://ports.ubuntu.com/ubuntu-ports bionic/universe armhf Packages
  Hash Sum mismatch
  Hashes of expected file:
   - Filesize:10952440 [weak]
   - SHA256:2a96d24bf4bc145b70c6a8277d260612b8ec0d7809a9a430d7b94979f2b72e7d
   - SHA1:e80857f8c522f917dc7c8bb5d349fc1c23d4b0cb [weak]
   - MD5Sum:ea51b85377313c571246771e62d9f42f [weak]
  Hashes of received file:
   - SHA256:7ca8bf6e1559853dc4f096bf9bb7b87981cc0a0b2368bee75464a922a0ee29de
   - SHA1:1b7ecd65892b1a91f32dc5b3d0e8a4d21be0d403 [weak]
   - MD5Sum:304d6607acc4fe62d964414c9a987fe4 [weak]
   - Filesize:10952440 [weak]
  Last modification reported: Thu, 26 Apr 2018 22:52:38 +0000
  Release file created at: Thu, 26 Apr 2018 23:37:48 +0000
Get:9 http://ports.ubuntu.com/ubuntu-ports bionic-updates/multiverse armhf Packages [3824 B]
Get:10 http://ports.ubuntu.com/ubuntu-ports bionic-updates/restricted armhf Packages [10.1 kB]
Get:11 http://ports.ubuntu.com/ubuntu-ports bionic-updates/universe armhf Packages [1038 kB]
Get:12 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main armhf Packages [661 kB]
Get:13 http://ports.ubuntu.com/ubuntu-ports bionic-backports/universe armhf Packages [3932 B]
Get:14 http://ports.ubuntu.com/ubuntu-ports bionic-backports/main armhf Packages [2490 B]
Get:15 http://ports.ubuntu.com/ubuntu-ports bionic-security/multiverse armhf Packages [1910 B]
Get:16 http://ports.ubuntu.com/ubuntu-ports bionic-security/main armhf Packages [380 kB]
Get:17 http://ports.ubuntu.com/ubuntu-ports bionic-security/restricted armhf Packages [5013 B]
Get:18 http://ports.ubuntu.com/ubuntu-ports bionic-security/universe armhf Packages [582 kB]
Fetched 15.6 MB in 36s (430 kB/s)
Reading package lists...
E: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/dists/bionic/universe/binary-armhf/by-hash/SHA256/2a96d24bf4bc145b70c6a8277d260612b8ec0d7809a9a430d7b94979f2b72e7d  Hash Sum mismatch
   Hashes of expected file:
    - Filesize:10952440 [weak]
    - SHA256:2a96d24bf4bc145b70c6a8277d260612b8ec0d7809a9a430d7b94979f2b72e7d
    - SHA1:e80857f8c522f917dc7c8bb5d349fc1c23d4b0cb [weak]
    - MD5Sum:ea51b85377313c571246771e62d9f42f [weak]
   Hashes of received file:
    - SHA256:7ca8bf6e1559853dc4f096bf9bb7b87981cc0a0b2368bee75464a922a0ee29de
    - SHA1:1b7ecd65892b1a91f32dc5b3d0e8a4d21be0d403 [weak]
    - MD5Sum:304d6607acc4fe62d964414c9a987fe4 [weak]
    - Filesize:10952440 [weak]
   Last modification reported: Thu, 26 Apr 2018 22:52:38 +0000
   Release file created at: Thu, 26 Apr 2018 23:37:48 +0000
E: Some index files failed to download. They have been ignored, or old ones used instead.
The command '/bin/sh -c apt-get update && apt-get install -y     git     software-properties-common     python3-pip git' returned a non-zero code: 100

EDIT: the problem seems to be at git and also at apt-get install git or because running both separately give me the following error:

The following additional packages will be installed:
  ca-certificates cron dbus dirmngr distro-info-data file gir1.2-glib-2.0
  gnupg gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client gpg-wks-server
  gpgconf gpgsm iso-codes libapparmor1 libapt-inst2.0 libasn1-8-heimdal
  libassuan0 libdbus-1-3 libexpat1 libgirepository-1.0-1 libglib2.0-0
  libglib2.0-data libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal
  libheimntlm0-heimdal libhx509-5-heimdal libicu60 libkrb5-26-heimdal libksba8
  libldap-2.4-2 libldap-common libmagic-mgc libmagic1 libmpdec2 libnpth0
  libpython3-stdlib libpython3.6-minimal libpython3.6-stdlib libreadline7
  libroken18-heimdal libsasl2-2 libsasl2-modules libsasl2-modules-db
  libsqlite3-0 libssl1.1 libwind0-heimdal libxml2 lsb-release mime-support
  openssl pinentry-curses powermgmt-base python-apt-common python3 python3-apt
  python3-dbus python3-gi python3-minimal python3-software-properties
  python3.6 python3.6-minimal readline-common shared-mime-info ucf
  unattended-upgrades xdg-user-dirs xz-utils
Suggested packages:
  anacron logrotate checksecurity exim4 | postfix | mail-transport-agent
  default-dbus-session-bus | dbus-session-bus dbus-user-session libpam-systemd
  pinentry-gnome3 tor parcimonie xloadimage scdaemon isoquery
  libsasl2-modules-gssapi-mit | libsasl2-modules-gssapi-heimdal
  libsasl2-modules-ldap libsasl2-modules-otp libsasl2-modules-sql lsb
  pinentry-doc python3-doc python3-tk python3-venv python3-apt-dbg
  python-apt-doc python-dbus-doc python3-dbus-dbg python3.6-venv python3.6-doc
  binutils binfmt-support readline-doc bsd-mailx default-mta
  | mail-transport-agent needrestart
The following NEW packages will be installed:
  ca-certificates cron dbus dirmngr distro-info-data file gir1.2-glib-2.0
  gnupg gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client gpg-wks-server
  gpgconf gpgsm iso-codes libapparmor1 libapt-inst2.0 libasn1-8-heimdal
  libassuan0 libdbus-1-3 libexpat1 libgirepository-1.0-1 libglib2.0-0
  libglib2.0-data libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal
  libheimntlm0-heimdal libhx509-5-heimdal libicu60 libkrb5-26-heimdal libksba8
  libldap-2.4-2 libldap-common libmagic-mgc libmagic1 libmpdec2 libnpth0
  libpython3-stdlib libpython3.6-minimal libpython3.6-stdlib libreadline7
  libroken18-heimdal libsasl2-2 libsasl2-modules libsasl2-modules-db
  libsqlite3-0 libssl1.1 libwind0-heimdal libxml2 lsb-release mime-support
  openssl pinentry-curses powermgmt-base python-apt-common python3 python3-apt
  python3-dbus python3-gi python3-minimal python3-software-properties
  python3.6 python3.6-minimal readline-common shared-mime-info
  software-properties-common ucf unattended-upgrades xdg-user-dirs xz-utils
0 upgraded, 73 newly installed, 0 to remove and 7 not upgraded.
Need to get 23.0 MB of archives.
After this operation, 98.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] Abort.
The command '/bin/sh -c apt-get install software-properties-common' returned a non-zero code: 1
-- M. Awais Jadoon
docker
kubernetes
raspberry-pi

1 Answer

7/2/2019

Solved the problem with a few changes in the Dockerfile. The problem was with spacing I think and I had to put RUN for some commands plus -y tag helped at some places for the reasons I don't know. Would like if someone could explain more.

FROM ubuntu:18.04

RUN apt-get update && apt-get install -y
RUN apt-get install git -y
RUN apt-get install software-properties-common -y

RUN add-apt-repository universe
RUN apt-get update
RUN apt-get install python3-pip git -y
RUN pip3 install tornado sqlalchemy construct==2.5.5-reupload
RUN apt-get install gnutls-bin -y
RUN git clone https://github.com/majadoon/empower-runtime.git
RUN cd empower-runtime && \
    mkdir deploy

EXPOSE 8888 4433

WORKDIR /empower-runtime

CMD ["./empower-runtime.py"]
-- M. Awais Jadoon
Source: StackOverflow