java docker java7 安装失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25019183/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
docker java7 install fail
提问by Will Lopez
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:
我正在尝试通过 ppa (RUN add-apt-repository ppa:webupd8team/java -y) 在我的 docker 映像中安装 java7,但它失败并出现以下错误:
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.
以下是正确安装的建议方法,但它不起作用。我也试过两种ppas。
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 assumethat if I can resolve this issue the aforementioned python step will install as needed:
add-apt-repository 似乎是 python-software-properties 安装的一部分。除了在构建的其他区域弹出的这些消息之外,我在该步骤中没有看到任何真正的错误。所以我假设如果我能解决这个问题,前面提到的 python 步骤将根据需要安装:
[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
所以。如何设置术语或对话框?我认为 -y 允许这样做
回答by Chris McKinnel
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.
在-y
你的apt-get install
命令告诉apt-get
“承担起是”,这是不一样的非交互模式下运行。
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:
您看到“无法初始化前端:对话框”消息,因为 Debianapt-get
以交互模式运行。要让它在非交互模式下运行,请将此行添加到 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.
现在您的命令将在非交互模式下运行,因此apt-get
不会尝试弹出任何对话框。
As for your actual error, you're right, add-apt-respository
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.
至于你的实际错误,你是对的,add-apt-respository
是python-software-properties
. 尝试将您的apt-get update -y
命令置于您的命令之上apt-get install python-software-properties
。
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 update -y
命令,一个在开始之前(总是一个好习惯),一个在您添加 oracle java PPA 之后。
回答by nacyot
add-apt-repository
command is a part of software-properties-common pakage. Install software-properties-common, not python-software-properties.
add-apt-repository
命令是 software-properties-common 包的一部分。安装 software-properties-common,而不是 python-software-properties。
Then you can add ppa:webupd8team repository. But there is still a problem.
然后你可以添加 ppa:webupd8team 存储库。但是还有一个问题。
Set the accepted-oracle-license-v1-1 and install java. Below sample Dockerfile will work perfectly.
设置accepted-oracle-license-v1-1并安装java。下面的示例 Dockerfile 将完美运行。
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
回答by Will Lopez
I tried a few different things to no avail so I went with OpenJDK instead. This got me past this step and unto the next error :-).
我尝试了一些不同的方法但无济于事,所以我改用 OpenJDK。这让我通过了这一步并进入下一个错误:-)。
# method 2
RUN apt-get install openjdk-7-jre -y