安装镜像组件指南(AI平台使用)

本文档详述了在Centos7和Ubuntu系统下,如何使用Dockerfile和手动方式安装openssh、openssl及jupyterlab,并配置tini,生成新镜像并上传至AI平台。涉及在线与离线安装,以及问题解决方案。
摘要由CSDN通过智能技术生成

目录

一、Centos7系统

1.1 Dockerfile安装组件

1.2 手动安装组件

1.2.1 在线安装

1.2.2 离线安装

二、Ubuntu系统

2.1 Dockerfile安装组件

2.2 手动安装组件

2.2.1 在线安装

2.2.2 离线安装

三、配置tini

四、生成新镜像

五、上传AI平台

六、问题解决


       说明:离线安装,也需要在线下载所有组件和依赖包后,拷贝到离线环境,去制作镜像。建议在线制作,因为在线可以自动下载所有组件,不会因为缺少组件或依赖,导致制作的镜像出现问题。文档包含离线和在线安装命令,请根据需要进行使用。

        文档中的组件版本,都是示例,请根据需要,进行安装和更新版本。文档中的Dockerfile只提供安装openssh、jupyter和python组件,是为了适配AI平台,如果FROM镜像中,有python3可以屏蔽安装python3的部分命令。

注意:jupyterlab必须使用python3及以上版本,如果使用python2,不建议安装jupyterlab,或者自己去找jupyter早期版本,根据需要进行修改。文档中的Dockerfile只支持python3的jupyterlab安装,不支持python2.

如果没有最终失败,Dockerfile在线制作镜像输出的红色内容,请忽略,不影响最终制作的镜像

一、Centos7系统

1.1 Dockerfile安装组件

Dockerfile下载链接:

https://github.com/wjyzzu/inpsur-dockerfile/tree/main/base/centos

Dockerfile文件内容

#base image

FROM centos:latest

MAINTAINER wjy



# install openssh and openssl

RUN set -ex \

&& yum install -y openssh-clients openssh-server openssl \

&& mkdir -p /var/run/sshd \

&& /usr/bin/ssh-keygen -A

    

# Allow OpenSSH to talk to containers without asking for confirmation

RUN set -ex \

&& cat /etc/ssh/ssh_config | grep -v StrictHostKeyChecking > /etc/ssh/ssh_config.new \

&& echo "    StrictHostKeyChecking no" >> /etc/ssh/ssh_config.new \

&& cat /etc/ssh/sshd_config | grep -v  PermitRootLogin> /etc/ssh/sshd_config.new \

&& echo "PermitRootLogin yes" >> /etc/ssh/sshd_config.new \

&& mv /etc/ssh/ssh_config.new /etc/ssh/ssh_config \

&& mv /etc/ssh/sshd_config.new /etc/ssh/sshd_config



# start install python3

## python version

ARG python=3.6.11

ENV PYTHON_VERSION=${python}



RUN yum clean packages \

&& yum -y install wget make zlib zlib-devel bzip2-devel openssl-devel sqlite-devel readline-devel gdbm-devel  gcc libffi-devel \

&& cd /home \

&& wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz \

&& tar -zxvf Python-${PYTHON_VERSION}.tgz \

&& cd Python-${PYTHON_VERSION} \

&& ./configure \

&& make \

&& make install \

&& make clean \

&& rm -rf Python-${PYTHON_VERSION}



## set python3

RUN set -ex \

&& if [ -e /usr/bin/python ]; then mv /usr/bin/python /usr/bin/python27; fi \

    && if [ -e /usr/bin/pip ]; then mv /usr/bin/pip /usr/bin/pip-python27; fi \

    && ln -s /usr/local/bin/python3 /usr/bin/python \

    && ln -s /usr/local/bin/pip3 /usr/bin/pip



# modify configuration

RUN set -ex \

    && sed -i "s#/usr/bin/python#/usr/bin/python2.7#" /usr/bin/yum \

    && if [ -e /usr/libexec/urlgrabber-ext-down ]; then sed -i "s#/usr/bin/python#/usr/bin/python2.7#" /usr/libexec/urlgrabber-ext-down; fi

# end install python3



# install jupyterlab                                                                                                                                        

RUN set -ex \

&& pip install --upgrade pip \

&& pip --no-cache-dir install jupyterlab \

&& rm -rf /root/.cache/pip/http/*  



## configure jupyterlab                                                                                                                                            

RUN set -ex \

&& mkdir /etc/jupyter/ \

&& wget -P /etc/jupyter/  https://raw.githubusercontent.com/Winowang/jupyter_gpu/master/jupyter_notebook_config.py \

&& wget -P /etc/jupyter/ https://raw.githubusercontent.com/Winowang/jupyter_gpu/master/custom.js



## tini

ENV TINI_VERSION v0.18.0

ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini

RUN chmod +x /tini
  1.        (1)根据制作情况,修改FROM中的基础镜像
  2.        (2)如果需要指定python3版本,可以在build时使用--build-arg python=3.7.9类似命令修改版本,默认python版本3.6.11,示例:
docker build --build-arg python=3.7.9 -t centos7.4-cuda9.0-cudnn7.0-base-inspur:latest -f /home/wjy/image_components/Dockerfile .

      (3)同时,可以修改Dockerfile文件,指定jupyterlab版本,双等号后面指定版本jupyterlab==2.2.9,示例:

pip --no-cache-dir install jupyterlab==2.2.9

1.2 手动安装组件

1.2.1 在线安装

      在线安装组件命令,Dockerfile文件里面都有,根据需要,docker run进入容器,执行相应命令,进行手动在线安装。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

莹火233

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值