因为有个算法是python写的,要在服务器上调用,
之前是直接根据jdk镜像制作的环境,现在要装python,jdk双环境,只能自己制作一个镜像出来了,命令如下
FROM ubuntu:20.04 ENV TZ=Asia/Shanghai ENV LANG C.UTF-8 RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak COPY sources.list /etc/apt/sources.list RUN apt update && apt install -y tzdata && echo "Asia/Shanghai" > /etc/timezone && rm -f /etc/localtime && dpkg-reconfigure -f noninteractive tzdata && apt install build-essential -y && apt install libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libbz2-dev -y && apt-get install zlib1g-dev WORKDIR /opt COPY Python-3.11.4.tgz Python-3.11.4.tgz RUN tar -zxvf Python-3.11.4.tgz WORKDIR /opt/Python-3.11.4 RUN ./configure --enable-optimizations \ && make \ && make install \ && apt-get install python3-pip -y \ && pip3 install pandas \ && pip3 install skyfield \ && apt install openjdk-8-jdk-headless -y
source.list
deb http://cn.archive.ubuntu.com/ubuntu/ focal main restricted deb http://cn.archive.ubuntu.com/ubuntu/ focal-updates main restricted deb http://cn.archive.ubuntu.com/ubuntu/ focal universe deb http://cn.archive.ubuntu.com/ubuntu/ focal-updates universe deb http://cn.archive.ubuntu.com/ubuntu/ focal multiverse deb http://cn.archive.ubuntu.com/ubuntu/ focal-updates multiverse deb http://cn.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse deb http://security.ubuntu.com/ubuntu focal-security main restricted deb http://security.ubuntu.com/ubuntu focal-security universe deb http://security.ubuntu.com/ubuntu focal-security multiverse
然后根据这个build成功后,From这个镜像就可以了
docker build -t="xxxx/ubuntu-python-jdk:1.0" . //构建镜像 docker run -it --name demo1 -d xxxx/ubuntu-python-jdk:1.0 /bin/bash //启动镜像可以进去看看环境 docker save -o ubu-jdk-py.tar xxxx/ubuntu-python-jdk:1.0 //保存镜像 docker load -i ubu-jdk-py.tar //去服务器载入镜像
标签:http,python,apt,&&,ubuntu,docker,com,deb From: https://www.cnblogs.com/moerjiana/p/17495639.html