Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker java7 install fail

Tags:

java

docker

I'm trying to install java7 via ppa (RUN add-apt-repository ppa:webupd8team/java -y) in my docker image but it fails with this error:

returned a non-zero code: 127 

The following are suggested ways to install correctly but it's not working. I've tried both ppas as well.

RUN  apt-get install python-software-properties -y RUN  add-apt-repository ppa:webupd8team/java -y #RUN add-apt-repository ppa:eugenesan/java -y RUN apt-get update RUN  apt-get install oracle-java7-installer -y 

Here is the log output:

Step 28 : RUN  add-apt-repository ppa:webupd8team/java -y  ---> Running in b278761a4209  [91m/bin/sh: 1: add-apt-repository: not found  [0m  

So...I need to find out where/if this command exist in a helper lib or what:

add-apt-repository 

add-apt-repository appears to be a part of the python-software-properties install. I don't see any real errors in that step except for these messages which pop up in other areas of the build. So I assume that if I can resolve this issue the aforementioned python step will install as needed:

    [91mdebconf: unable to initialize frontend: Dialog      debconf: (TERM is not set, so the dialog frontend is not usable.)      debconf: falling back to frontend: Readline      [0m[91mdebconf: unable to initialize frontend: Readline      debconf: (This frontend requires a controlling tty.)      debconf: falling back to frontend: Teletype      [0m[91mdpkg-preconfigure: unable to re-open stdin:  

So. How to set a term or dialog up? I thought the -y allowed this

like image 417
Will Lopez Avatar asked Jul 29 '14 15:07

Will Lopez


2 Answers

The -y in your apt-get install commands is telling apt-get to "assume yes", which isn't the same as running in non-interactive mode.

You're seeing the "unable to initialize frontend: Dialog" messages because Debian is running apt-get in interactive mode. To tell it to run in non-interactive mode, add this line to the start of your Dockerfile:

ENV DEBIAN_FRONTEND noninteractive 

Now your commands will be running in non-interactive mode, so apt-get won't try and pop any dialogs up.

As for your actual error, you're right, add-apt-repository is a part of the python-software-properties. Try putting your apt-get update -y command above your apt-get install python-software-properties command.

RUN apt-get update -y                             && \     apt-get install python-software-properties -y && \     add-apt-repository ppa:webupd8team/java -y    && \     apt-get update -y                             && \     apt-get install oracle-java7-installer -y     && \     oracle-java7-set-default 

Note, you'll need to do two apt-get update -y commands, one before you start (always a good habit to get into) and one after you've added the oracle java PPA.

apt-get manual

Docker ENV docs

like image 197
Chris McKinnel Avatar answered Oct 19 '22 14:10

Chris McKinnel


add-apt-repository command is a part of software-properties-common pakage. Install software-properties-common, not python-software-properties.

Then you can add ppa:webupd8team repository. But there is still a problem.

Set the accepted-oracle-license-v1-1 and install java. Below sample Dockerfile will work perfectly.

FROM ubuntu:14.04  RUN apt-get update RUN apt-get install software-properties-common -y RUN add-apt-repository ppa:webupd8team/java -y RUN apt-get update RUN echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections RUN apt-get install oracle-java7-installer -y 
like image 35
nacyot Avatar answered Oct 19 '22 15:10

nacyot