Creating Linux Desktop. Installing OpenJDK "returned a non-zero code: 127"

First post, so please let me know if this isn’t the right spot in the forum or if I need to edit my post. Thanks.

I’m attempting to slightly modify a Dockerfile so that Java SDK is also installed, and I’m completely lost as to what to do here. I like this particular Dockerfile because it has everything I need, minus Java. I added the commands to install Java and I’m getting an error and not sure what to do. Any help is greatly appreciated! Cheers.

Behavior

The command ‘/bin/sh -c add-apt-repository ppa:openjdk-r/ppa && apt-get update && apt-get install openjdk-8-jdk -y’ returned a non-zero code: 127

Information

  • Currently using Windows 10 to build a Docker Container to run on a NetPI.
  • Using Windows 10, PowerShell
  • Successfully built several other Docker images

Here is the dockerfile, obtained from hilschernetPi

#use fixed armv7hf compatible debian version from group resin . io as base image
FROM resin/armv7hf-debian:stretch

#enable building ARM container on x86 machinery on the web (comment out next line if built on Raspberry)
RUN [ “cross-build-start” ]

#labeling
LABEL maintainer=“netpi @ hilscher .com” \
version=“V1.2.1”
description=“Desktop (HDMI) for netPI”

#version
ENV HILSCHERNETPI_DESKTOP_HDMI_VERSION 1.2.1

ENV USER=testuser
ENV PASSWD=mypassword

#copy files
COPY “./init.d/*” /etc/init.d/

#do user
RUN apt-get update
&& useradd --create-home --shell /bin/bash $USER
&& echo $USER:$PASSWD | chpasswd
&& adduser $USER tty
&& adduser $USER video
&& adduser $USER sudo
&& adduser $USER input
&& echo $USER " ALL=(root) NOPASSWD:ALL" >> /etc/sudoers.d/$USER
&& chmod 0440 /etc/sudoers.d/$USER

#install ssh
RUN apt-get update
&& apt-get install -y openssh-server
&& sed -i ‘s/#PermitRootLogin prohibit-password/PermitRootLogin yes/’ /etc/ssh/sshd_config
&& sed ‘s@session\srequired\spam_loginuid.so@session optional pam_loginuid.so@g’ -i /etc/pam.d/sshd
&& mkdir /var/run/sshd

#install xserver, desktop, login manager, ALSA sound driver
RUN apt-get install --no-install-recommends xserver-xorg
&& apt-get install --no-install-recommends xinit
&& apt-get install xfce4 xfce4-terminal
&& mkdir /etc/X11/xorg.conf.d
&& chmod u+s /usr/bin/Xorg
&& chown -c $USER /etc/X11/xorg.conf.d
&& apt-get install xserver-xorg-input-evdev
&& apt-get install gnome-icon-theme tango-icon-theme
&& apt-get install alsa-oss alsa-tools alsa-tools-gui alsa-utils alsamixergui mpg123
&& touch /home/$USER/.Xauthority
&& chmod 777 /home/$USER/.Xauthority

#install Java. This isn’t working
RUN add-apt-repository ppa:openjdk-r/ppa
&& apt-get update
&& apt-get install openjdk-8-jdk -y

#install VNC
RUN apt-get install x11vnc
&& mkdir /home/$USER/.vnc
&& chown $USER:$USER /home/$USER/.vnc
&& x11vnc -storepasswd “$PASSWD” /home/$USER/.vnc/passwd
&& chown $USER:$USER /home/$USER/.vnc/passwd

#install pulseaudio
RUN apt-get install dbus-x11 pulseaudio
&& sed -i -e ‘s;load-module module-console-kit;#load-module module-console-kit;’ /etc/pulse/default.pa
&& usermod -a -G audio $USER
&& usermod -a -G pulse $USER
&& usermod -a -G pulse-access $USER

#install chromium browser
RUN apt-get install wget
&& wget -O key.pgp https:/ /bintray.com / user/downloadSubjectPublicKey?username=bintray
&& apt-key add key.pgp
&& echo “deb http : //dl . bintray . com / kusti8/chromium-rpi jessie main” | tee -a /etc/apt/sources.list
&& apt-get update
&& apt-get install chromium-browser
&& rm key.pgp

#set the entrypoint
ENTRYPOINT [“/etc/init.d/entrypoint.sh”]
#SSH port
EXPOSE 22
#set STOPSGINAL
STOPSIGNAL SIGTERM
#stop processing ARM emulation (comment out next line if built on Raspberry)
RUN [ “cross-build-end” ]

#start container as non-root user, else chromium will not run
USER $USER

-----------------------------DEBUG FILE----------------------------------

Sending build context to Docker daemon 3.591MB
Step 1/19 : FROM resin/armv7hf-debian:stretch
—> 86da310345e6
Step 2/19 : RUN [ “cross-build-start” ]
—> Using cache
—> 0f0cf14bc22d
Step 3/19 : LABEL maintainer=netpi @ hilscher . com version=“V1.2.1” description=“Desktop (HDMI) for netPI”
—> Using cache
—> 79eac42c416b
Step 4/19 : ENV HILSCHERNETPI_DESKTOP_HDMI_VERSION 1.2.1
—> Using cache
—> 903879c0a90d
Step 5/19 : ENV USER=testuser
—> Using cache
—> 2af9053020f2
Step 6/19 : ENV PASSWD=mypassword
—> Using cache
—> 07e84a7d8257
Step 7/19 : COPY "./init.d/" /etc/init.d/
—> Using cache
—> 5f8e9b0a23ea
Step 8/19 : RUN apt-get update && useradd --create-home --shell /bin/bash $USER && echo $USER:$PASSWD | chpasswd && adduser $USER tty && adduser $USER video && adduser $USER sudo && adduser $USER input && echo $USER " ALL=(root) NOPASSWD:ALL" >> /etc/sudoers.d/$USER && chmod 0440 /etc/sudoers.d/$USER
—> Using cache
—> ac2cf2be000c
Step 9/19 : RUN apt-get update && apt-get install -y openssh-server && sed -i ‘s/#PermitRootLogin prohibit-password/PermitRootLogin yes/’ /etc/ssh/sshd_config && sed 's@session\s
required\s*pam_loginuid.so@session optional pam_loginuid.so@g’ -i /etc/pam.d/sshd && mkdir /var/run/sshd
—> Using cache
—> 6edee81b6066
Step 10/19 : RUN apt-get install --no-install-recommends xserver-xorg && apt-get install --no-install-recommends xinit && apt-get install xfce4 xfce4-terminal && mkdir /etc/X11/xorg.conf.d && chmod u+s /usr/bin/Xorg && chown -c $USER /etc/X11/xorg.conf.d && apt-get install xserver-xorg-input-evdev && apt-get install gnome-icon-theme tango-icon-theme && apt-get install alsa-oss alsa-tools alsa-tools-gui alsa-utils alsamixergui mpg123 && touch /home/$USER/.Xauthority && chmod 777 /home/$USER/.Xauthority
—> Using cache
—> 01a79dde198b
Step 11/19 : RUN add-apt-repository ppa:openjdk-r/ppa && apt-get update && apt-get install openjdk-8-jdk -y
—> Running in 04c3dfed2852
e[91m/bin/sh: 1: e[0me[91madd-apt-repository: not found
e[0m

Hello,

Why don’t you use existing openjdk repository?

Here is an example:

Dockerfile

FROM openjdk:8-alpine3.8

CMD ["java", "-version"]

Usage

docker build -t myapp .
Sending build context to Docker daemon  15.82MB
Step 1/2 : FROM openjdk:8-alpine3.8
 ---> 54ae553cb104
Step 2/2 : CMD ["java", "-version"]
 ---> Running in b283dc654ebb
Removing intermediate container b283dc654ebb
 ---> f55103575069
Successfully built f55103575069
Successfully tagged myapp:latest

docker run --rm -it myapp
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (IcedTea 3.8.0) (Alpine 8.171.11-r0)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)
1 Like