一个包含python和java环境的dockerfile
Posted mzyn22
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一个包含python和java环境的dockerfile相关的知识,希望对你有一定的参考价值。
现在一个项目中遇到python调用java的jar包的环境。为了方便发布,编写了这个dockerfile,作为基础镜像。
1 #this docker file is used to build runtime environment. 2 #The project is a python app which contains a java jar lib. 3 FROM centos 4 MAINTAINER mzyn22 <mzyn22@163.com> 5 6 COPY ./requirements.txt /usr/local/src/requirements.txt 7 # update software resource 8 RUN yum -y install wget && 9 cd /etc/yum.repos.d/ && 10 mkdir bak && 11 mv *.repo bak && 12 wget http://mirrors.aliyun.com/repo/Centos-7.repo && 13 wget http://mirrors.aliyun.com/repo/epel-7.repo && 14 yum -y install zlib-devel bzip2-devel openssl-devel openssl-static ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel lzma gcc && 15 yum -y groupinstall "Development tools" && 16 yum -y install java-1.8.0-openjdk.x86_64 && 17 cd /usr/local/src/ && 18 wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz && 19 tar xvf Python-3.7.0.tar.xz && 20 mv Python-3.7.0 /usr/local/python-3.7 && 21 cd /usr/local/python-3.7/ && 22 ./configure --prefix=/usr/local/sbin/python-3.7 && 23 make && make install && 24 rm -rf /usr/bin/python && 25 ln -sv /usr/local/sbin/python-3.7/bin/python3 /usr/bin/python && 26 ln -sv /usr/local/sbin/python-3.7/bin/python3 /usr/bin/python3 && 27 ln -sv /usr/local/sbin/python-3.7/bin/python3 /usr/bin/python37 && 28 sed -i 1s/python/python2.7/ /usr/bin/yum && 29 sed -i 1s/python/python2.7/ /usr/libexec/urlgrabber-ext-down && 30 sed -i 1s/python/python2.7/ /usr/bin/yum-config-manager && 31 32 sed -i ‘$a\JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk.x86_64‘ /etc/profile && 33 sed -i ‘$a\PATH=$PATH:$JAVA_HOME/bin‘ /etc/profile && 34 sed -i ‘$a\CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar‘ /etc/profile && 35 sed -i ‘$a\export JAVA_HOME CLASSPATH PATH‘ /etc/profile && 36 source /etc/profile && 37 ln -s /usr/local/sbin/python-3.7/bin/pip3 /usr/bin/pip && 38 pip install --upgrade pip 39 40 RUN pip install -r /usr/local/src/requirements.txt
以上是关于一个包含python和java环境的dockerfile的主要内容,如果未能解决你的问题,请参考以下文章
Dockerfile07 -- Dockerfile构建python
Dockerfile07 -- Dockerfile构建python