跳至主要內容

上传自定义镜像示例

大约 2 分钟

基于dockerfile/外部仓库推送镜像

必须包含下列所有组件,否则无法正常使用

install cuda

FROM 214.3.7.25:5000/nvidia/cuda:12.5.0-runtime-ubuntu22.04

ENV DEBIAN_FRONTEND=noninteractive

WORKDIR /root

RUN rm -f /etc/apt/sources.list.d/* && \

RUN apt-get update && \

​    apt-get install -y wget software-properties-common && \

​    wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin && \

​    mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600 && \

​    apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub && \

​    add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /" && \

​    apt-get update && \

​    apt-get -y install cuda=12.5.0-1 && \

​    apt clean && \

​    rm -rf /var/lib/apt/lists/*  && \

​    rm -rf /root/*

install base software

FROM 214.3.7.25:5000/nvidia/cuda:12.3.2-cudnn8-runtime-ubuntu22.04-small

安装boot.sh启动脚本,启动supervisord进程

COPY boot.sh /init/boot/boot.sh

COPY supervisord/supervisord_static /bin/supervisord

COPY supervisord/supervisor.ini /init/supervisord/supervisor.ini

ENTRYPOINT ["bash","/init/boot/boot.sh"]

工作目录

WORKDIR /root/

安装openssh、webTerminal等功能软件包

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \

​    apt-get upgrade -y && \

​    apt-get install --no-install-recommends -y \

​        tar unrar rar unzip htop curl wget git \

​        p7zip-full gzip zip bzip2 sysstat jq iproute2 \

​        net-tools screen tmux nano vim ntpdate \

​        inetutils-ping telnet traceroute tcpdump \

​        iperf3 linux-kernel-headers build-essential \

​        gcc g++ make lrzsz cmake bmon parallel \

​        libgl1-mesa-dev pkg-config libgl1-mesa-glx \

​        linux-libc-dev nmap cron zsh dash \

​        openssh-server \

​        shellinabox && \

​    apt clean && \

​    rm -rf /var/lib/apt/lists/*

配置ssh

RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \

​    sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/g' /etc/ssh/sshd_config && \

​    sed -i 's/#UseDNS no/UseDNS no/g' /etc/ssh/sshd_config && \

​    mkdir -p -m 700 /root/.ssh/ && \

​    echo "# 此文件由系统自动创建,请勿删除或修改." > /root/.ssh/authorized_keys && \

​    chmod 600 /root/.ssh/authorized_keys && \

​    mkdir /var/run/sshd

安装code-server

ADD code-server/code-server-4.90.3-linux-amd64.tar.gz /usr/local/

RUN mv /usr/local/code-server-4.90.3-linux-amd64 /usr/local/code-server

安装文件管理

ADD filebrowser/filebrowser.tgz /etc/

RUN mv /etc/filebrowser/filebrowser /usr/local/bin/

安装miniconda

\# py37

COPY miniconda/Miniconda3-py37_23.1.0-1-Linux-x86_64.sh ./miniconda.sh

\# py38

COPY miniconda/Miniconda3-py38_23.11.0-2-Linux-x86_64.sh ./miniconda.sh

py39

COPY miniconda/Miniconda3-py39_24.4.0-0-Linux-x86_64.sh ./miniconda.sh

py310

\#COPY miniconda/Miniconda3-py310_24.4.0-0-Linux-x86_64.sh ./miniconda.sh

\# py312

COPY miniconda/Miniconda3-py312_24.4.0-0-Linux-x86_64.sh ./miniconda.sh

RUN bash /root/miniconda.sh -b -f -p /root/miniconda && \

​    bash -c '/root/miniconda/bin/conda config --set auto_activate_base false' && \

​    rm -f /root/miniconda.sh

配置容器内环境变量

ENV PATH="/root/miniconda/bin:/usr/local/code-server/bin/:${PATH}"

ENV LANG="en_US.UTF-8"

ENV LANGUAGE="en_US:en"

ENV PASSWORD="!G@sip02o22"

生效配置文件

COPY tools/lanyun-motd /etc/lanyun-motd

RUN echo 'source /etc/profile\nsource /etc/lanyun-motd' >> /root/.bashrc

安装jupyterlab

RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple \

​    jupyterlab jupyterlab_server jupyterlab-language-pack-zh-CN && \

​    rm -r /root/.cache/pip