[英]How to execute python program from spring boot java application in docker
I have spring boot java application.我有 spring 启动 java 应用程序。 For some of its api, it calls a python program(which is present in src folder eg abc.py) to get the output.对于它的一些 api,它调用 python 程序(存在于 src 文件夹中,例如 abc.py)来获取 output。
I have a dockerfile to dockerize the application.我有一个 dockerfile 来对接应用程序。 I am able to successfully build the image and container is runnning out of the image.我能够成功构建图像并且容器正在用完图像。 But when I call the api, it throws error and says python command not found.但是当我调用 api 时,它会抛出错误并显示 python 命令未找到。 Also when I go inside docker container, when I check for ' which python ', it does not show anything.此外,当我在 docker 容器内进行 go 时,当我检查“其中 python ”时,它没有显示任何内容。
For python install and making python environment variable set inside this docker, what should be mentioned in the dockerfile.对于 python 安装并在此 docker 中设置 python 环境变量,应在 Z60F5AD192689E665807E86EB0E2.Z.
FROM gradle:4.10.1-jdk8-alpine AS build
COPY --chown=gradle:gradle . /home/gradle/src
WORKDIR /home/gradle/src
RUN gradle build --no-daemon
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir -p /dispython
WORKDIR /dispython
COPY requirements.txt /dispython
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
RUN python --version
RUN which python
#ENV PYTHONPATH "${PYTHONPATH}:/dispython"
FROM openjdk:8-jre-slim
EXPOSE 8081
RUN mkdir /app
COPY --from=build /home/gradle/src/build/libs/*.jar /app/spring-boot
application.jar
ENTRYPOINT ["java", "-XX:+UnlockExperimentalVMOptions", "-
XX:+UseCGroupMemoryLimitForHeap", "-
Djava.security.egd=file:/dev/./urandom","-jar","/app/spring-
boot-application.jar"]
Advance thanks提前谢谢
If you really don't want to use docker-compose
(recommended), you still have to copy this *.py file to your container COPY src/ src/
...如果你真的不想使用docker-compose
(推荐),你还是要把这个 *.py 文件复制到你的容器中COPY src/ src/
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.