简体   繁体   English

如何从 spring 启动 java 应用程序在 Z05B6053C41A2130AFD6FC3BE158 中执行 python 程序

[英]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.

相关问题 如何从spring boot调用python程序? - How to call a python program from spring boot? 如何从 Linux 命令行或 docker 容器中检查 spring 启动 java 应用程序消耗了哪些值 - How to check what values are consumed by a spring boot java application from the Linux command line or in the docker container 如何从 docker shell 脚本(入口点)调用 spring-boot java 应用程序? - How to call a spring-boot java application from docker shell script (entrypoint)? 如何从docker容器内的java / spring-boot项目运行python脚本(并接收输出)? - How to run python script (and receive output) from java/spring-boot project which is inside a docker container? 如何将 Spring 引导应用程序部署到 Docker? - How to deploy Spring Boot Application to Docker? 如何通过Java程序执行docker命令 - how to execute docker commands through Java program 在 java Spring 引导应用程序中执行 Kotlin 脚本 - Execute Kotlin scripts inside java Spring Boot Application 无法执行Spring Boot应用程序 - Failed to execute spring boot application Spring Boot-当程序失去与数据库的连接时如何执行方法? - Spring Boot - How to execute a method when program loses connection to DB? Java-从Spring Boot应用程序获取变量 - Java - Get variable from Spring Boot Application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM