Shashank Rawat
Shashank Rawat

Reputation: 85

Run a docker image with java and python

I have a spring boot app which I have dockerized using DockerFile now my spring boot app also runs a python script for which I will need a python environment in the same docker image. how do I modify my Dockerfile so that I achieve the above functionality? Also please tell me what will be the python home in that case. my DockerFile is as follows:

FROM openjdk:11
ADD target/python-service-0.0.1-SNAPSHOT.jar python-service-0.0.1-SNAPSHOT.jar
EXPOSE 9091
ENTRYPOINT ["java", "-jar", "python-service-0.0.1-SNAPSHOT.jar"]

Upvotes: 0

Views: 4340

Answers (1)

Leletir
Leletir

Reputation: 111

Depending if you need python 2 or 3 ? Python 2.7.13 is by default in the image. So you will be able to use it. If you need python3 you will have to create a custom Docker Image:

FROM openjdk:11
EXPOSE 9091
RUN apt-get update && apt-get install python3
ADD target/python-service-0.0.1-SNAPSHOT.jar python-service-0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java", "-jar", "python-service-0.0.1-SNAPSHOT.jar"]

Hope it helps.

Upvotes: 1

Related Questions