我正在尝试将Python包装器用于名为Tabula的Java库。我在Docker容器中需要Python和Java映像。我使用的是openjdk:8
和python:3.5.3
图片。我正在尝试使用Docker-compose构建文件,但它返回以下消息:
/bin/sh: 1: java: not found
当它到达Dockerfile中的行RUN java -version
时。行RUN find / -name "java"
也没有返回任何内容,因此我甚至无法找到Docker环境中安装Java的位置。
这是我的Dockerfile:
FROM python:3.5.3
FROM openjdk:8
FROM tailordev/pandas
RUN apt-get update && apt-get install -y \
python3-pip
# Create code directory
ENV APP_HOME /usr/src/app
RUN mkdir -p $APP_HOME/temp
WORKDIR /$APP_HOME
# Install app dependencies
ADD requirements.txt $APP_HOME
RUN pip3 install -r requirements.txt
# Copy source code
COPY *.py $APP_HOME/
RUN find / -name "java"
RUN java -version
ENTRYPOINT [ "python3", "runner.py" ]
如何在Docker容器中安装Java,以便Python包装类可以调用Java方法?
答案 0 :(得分:2)
此Dockerfile无法正常工作,因为开头的多个=COUNTIF(G1:INDIRECT("G"&COUNTA(A1:A100)),1)
语句并不代表您认为的含义。它并不意味着您在FROM
语句中引用的图像的所有内容都将以您以某种方式构建的图像结束,它实际上意味着两个不同的概念贯穿始终码头工人的历史:
您所描述的行为让我假设您使用的是此类早期版本。让我解释一下在这个Dockerfile上运行FROM
时实际发生的事情:
docker build
如你所见,这不是你想要的。
您应该做的是构建一个单独的映像,您将首先安装运行时(python,java,..),然后安装特定于应用程序的依赖项。您已经在做的最后两部分,以下是如何安装一般依赖项的方法:
FROM python:3.5.3
# Docker: "The User wants me to build an
Image that is based on python:3.5.3. No Problem!"
# Docker: "Ah, the next FROM Statement is coming up,
which means that the User is done with building this image"
FROM openjdk:8
# Docker: "The User wants me to build an Image that is based on openjdk:8. No Problem!"
# Docker: "Ah, the next FROM Statement is coming up,
which means that the User is done with building this image"
FROM tailordev/pandas
# Docker: "The User wants me to build an Image that is based on python:3.5.3. No Problem!"
# Docker: "A RUN Statement is coming up. I'll put this as a layer in the Image the user is asking me to build"
RUN apt-get update && apt-get install -y \
python3-pip
...
# Docker: "EOF Reached, nothing more to do!"
请注意,我还没有对上述代码段进行过测试,您可能需要调整一些内容。