乐趣区

关于python:构建python基础镜像


FROM nvidia/cuda:11.3.0-runtime-ubuntu20.04

MAINTAINER yyq

#增加 python 的安装包
ADD Python-3.7.10.tar.xz /opt
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak
COPY sources.list /etc/apt/sources.list
RUN chmod a+x /etc/apt/sources.list

#不做交互
ENV DEBIAN_FRONTEND=noninteractive
#更新 apt
RUN apt-get update

RUN mkdir /root/.pip
COPY pip.conf /root/.pip/.

RUN mkdir /usr/local/python-3.7
#装置依赖

RUN apt-get install gcc -y && apt-get install make -y \
        && apt-get install vim -y && apt-get install openssl -y \
        && apt-get install libssl-dev -y && apt-get install python3-pip -y
RUN /opt/Python-3.7.10/configure --prefix=/usr/local/python-3.7 \
        && make && make install

RUN apt-get install vim ffmpeg libsm6 libxext6 cron openssh-server -y
RUN pip install aio-pika==7.1.0 asyncio==3.4.3 APScheduler==3.7.0 matplotlib==3.3.4 opencv-python==4.5.2.52 && Pillow==8.2.0 pika==1.2.0 pymongo==3.11.4 requests==2.25.1
RUN pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html

RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai'>/etc/timezone

RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/'  /etc/ssh/sshd_config
RUN sed -i 's/UsePAM yes/UsePAM no/' /etc/ssh/sshd_config
RUN echo "root:123456" | chpasswd

RUN echo  "alias ll='ls -l'" >> ~/.bash_profile
RUN /bin/bash -c 'source  ~/.bash_profile;'

CMD [""]


##########################
# 生成容器
docker run --name py_gpu --runtime=nvidia -it cuda11.3_py:v1
# 保留镜像
docker save -o cuda11.3_pytorch.tar cuda11.3_py:v1 


退出移动版