32

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

Will Lopez
  • 2,089
  • 3
  • 40
  • 64

3 Answers3

52

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

FooF
  • 4,323
  • 2
  • 31
  • 47
Chris McKinnel
  • 14,694
  • 6
  • 64
  • 67
  • No worries - enjoy docker! – Chris McKinnel Jul 29 '14 at 16:52
  • Yes, loving it so far. I've showed it to a few peers and they like it as well. It may replace our current vagrant solutions if I can get this spike done. – Will Lopez Jul 29 '14 at 16:56
  • I found I also needed these two lines from http://askubuntu.com/a/190674: RUN echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections RUN echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections – michielbdejong Dec 03 '15 at 11:06
14

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
nacyot
  • 3,312
  • 1
  • 17
  • 10
  • 1
    The accepted answer did not help with this exact problem. I'm so glad I tried your solution. Worked like a charm. – codenaugh Jun 25 '15 at 01:04
  • for me, installing software-properties-common didnt work but installing python-software-properties from the answer above did. – markus_p Nov 05 '15 at 19:30
  • Work for me: echo password | mysqlrouter --bootstrap xxxxxxxxxx – Kandy Jan 04 '22 at 23:30
4

Way #1

Somebody said this way not working but i tested it works.

ENV DEBIAN_FRONTEND noninteractive

yes | apt-get install package-1 package-2

Way #2

ENV DEBIAN_FRONTEND noninteractive

apt-get install -y package-1 package-2
Binh Ho
  • 3,690
  • 1
  • 31
  • 31