使用dockerfile安装java成功,但是它没有找到java命令 [英] install java successfully using the dockerfile however its says java command not found
本文介绍了使用dockerfile安装java成功,但是它没有找到java命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的docker文件
运行apt-get install -y --no-install-recommendations软件属性 - common
RUN add-apt-repository -y ppa:openjdk -r / ppa
运行apt-get update
运行apt-get install -y openjdk-8-jdk
RUN apt-get install -y openjdk-8-jre
RUN update-alternatives --config java
RUN更新选项--config javac
当我使用 sudo docker运行-t -i dockerfile
登录容器,并键入java或javac它可以工作。我可以看到它已经安装成功,但是当我运行它下面的文件它说java命令没有找到?
运行apt-get install -y --no-install-recommended软件属性常见的
pre>
RUN add-apt-repository -y ppa:openjdk -r / ppa
RUN apt-get update
运行apt-get install -y openjdk-8-jdk
运行apt-get install -y openjdk-8-jre
运行update-alternatives --config java
RUN update-alternatives - -config javac
ENTRYPOINT [java-jar,/home/project/hello.jar]
CMD []
sudo docker运行-t -i dockerfile
java命令不发现
?解决方案
ENTRYPOINT [java-jar /home/project/hello.jar]
您在
之前忘记了一个逗号 - jar code>。
Here is my docker file
RUN apt-get install -y --no-install-recommends software-properties-common RUN add-apt-repository -y ppa:openjdk-r/ppa RUN apt-get update RUN apt-get install -y openjdk-8-jdk RUN apt-get install -y openjdk-8-jre RUN update-alternatives --config java RUN update-alternatives --config javac
when I log into the container using
sudo docker run -t -i dockerfile
and type java or javac it works. I can see it has been installed successfully however when i run it with the file below it says "java command not found"?RUN apt-get install -y --no-install-recommends software-properties-common RUN add-apt-repository -y ppa:openjdk-r/ppa RUN apt-get update RUN apt-get install -y openjdk-8-jdk RUN apt-get install -y openjdk-8-jre RUN update-alternatives --config java RUN update-alternatives --config javac ENTRYPOINT ["java" "-jar", "/home/project/hello.jar"] CMD [""]
sudo docker run -t -i dockerfile
java command not found
?解决方案
ENTRYPOINT ["java" "-jar", "/home/project/hello.jar"]
You forgot a comma before
"-jar"
.这篇关于使用dockerfile安装java成功,但是它没有找到java命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文