Skip to main content

Image component installation

To adapt to the AIStation platform, this document primarily describes the installation of the openssh, JupyterLab, and Python components. For installing or updating component versions, refer to the examples in this document. If Python 3 is already installed in the base image (the image specified in the FROM instruction), you can skip the Python 3 installation steps in this document. Note: JupyterLab requires Python 3 or later. The Dockerfile in this document only supports JupyterLab installation for Python 3 and does not support Python 2.

1. CentOS 7 System

1.1 Installing Components via Dockerfile

https://github.com/wjyzzu/inpsur-dockerfile/tree/main/base/centos Download the Dockerfile, which contains commands for installing the openssh, Python 3, and JupyterLab components.

1.1.2 Build Steps

(1) Modify the base image in the FROM instruction as needed. It is recommended to upload the base image to AIStation in advance.
(2) After modifying the Dockerfile, upload it to your personal user directory.
(3) Create a new image using the Image Management - Create feature.
(4) Create a development environment based on the built image for testing.
(5) Note: The default Python version in the above Dockerfile is 3.6.11. To specify a JupyterLab version, modify as shown in the following example: pip --no-cache-dir install jupyterlab==2.2.9

1.2 Manual Component Installation

1.2.1 Online Installation

(1) Upload the base image to AIStation.
(2) Select the base image to create a development environment. Refer to the Dockerfile in section 1.1, execute the installation commands, and complete the component installation.
(3) Save the image.

1.2.2 Offline Installation

If the AIStation platform cannot connect to the external network, refer to the following methods:
(1) Download the relevant software packages or dependencies, upload them to the user directory, create a development environment based on the base image, perform offline component installation in the development environment, and finally save the image to complete the image build via the AIStation platform.
(2) Install components online in an environment with normal network connectivity, save them as a tar package using docker save, and import them into AIStation using the AIStation - Image Management - Internal Import feature.
The following describes how to download and install components:

1.2.2.1 Installing openssh and openssl

(1) Download installation packages and dependency packages to a specified directory. Components to be installed:

openssh-7.4p1-21.el7.x86_64.rpm
openssh-clients-7.4p1-21.el7.x86_64.rpm
openssh-server-7.4p1-21.el7.x86_64.rpm

Based on the base image, mount the local directory, create a container, and download various components. Example:

docker run -it -v /home/inspur/image_components/centos7.4:/home/inspur/image_components /centos7.4 centos:centos7.4.1708 /bin/bash

You can use the following command to view the component packages required for yum installation:

yum list | grep PACKAGE_NAME

Download components for use in an offline environment:

## openssh
yum install --downloadonly --downloaddir=/home/inspur/image_components/centos7.4/openssh openssh-7.4p1-21.el7.x86_64
## openssl
yum install --downloadonly --downloaddir=/home/inspur/image_components/centos7.4/openssl openssl

(2) Install the openssh and openssl components

# Navigate to the package directory to install openssh
cd /home/wjy/image_components/centos7.4/openssh
rpm -ivh *.rpm --force --nodeps
# Install openssl
cd /home/wjy/image_components/centos7.4/openssh
rpm -ivh *.rpm --force --nodeps
# --nodeps means do not check dependencies during installation
# --force means force installation

(3) openssh configuration

# Create a new directory first; skip if it already exists
mkdir -p /run/sshd

# Execute ssh-keygen
/usr/bin/ssh-keygen -A
# Execute configuration:
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 -f /etc/ssh/ssh_config.new /etc/ssh/ssh_config && \
mv -f /etc/ssh/sshd_config.new /etc/ssh/sshd_config > /dev/null 2>&1;

1.2.2.2 Installing JupyterLab

To install JupyterLab, Python 3 and pip must be installed. (1) Install Python 3

yum install --downloadonly --downloaddir=/home/wjy/image_components/centos7.4/python_depends make zlib zlib-devel bzip2-devel openssl-devel sqlite-devel readline-devel gdbm-devel gcc libffi-devel

# Navigate to the downloaded dependency package directory and install the dependencies:
cd /home/wjy/image_components/centos7.4/python_depends
rpm -ivh *.rpm --force --nodeps

# Download the Python tgz package, extract it, and enter the directory
cd /home/wjy/image_components/python
wget https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tgz
tar -zxvf Python-3.7.6.tgz
cd Python-3.7.6
./configure
make && make install
# Modify the configuration
mv /usr/bin/python /usr/bin/python27
mv /usr/bin/pip /usr/bin/pip27
ln -s /usr/local/bin/python3 /usr/bin/python
ln -s /usr/local/bin/pip3 /usr/bin/pip
sed -i "s## /usr/bin/python## /usr/bin/python2.7## " /usr/bin/yum
sed -i "s## /usr/bin/python## /usr/bin/python2.7## " /usr/libexec/urlgrabber-ext-down

(2) Install pip3 on CentOS 7 (install only if pip3 is not already installed)

# Download get-pip.py and install pip
cd /home/wjy/image_components
wget https://bootstrap.pypa.io/get-pip.py
# Install pip
python get-pip.py

(3) Install JupyterLab

pip install jupyterlab # Online installation
cd /home/inspur/image_components/jupyterlab
pip3 install --no-index --find-links=/home/inspur/install_packages/jupyterlab jupyterlab-1.2.3-py2.py3-none-any.whl # Offline installation
jupyter lab --ip=0.0.0.0 --no-browser --allow-root # Run test to verify successful installation

(4) Jupyter configuration

# Download the configuration file
wget -P /home/inspur/image_components/jupyter_configure https://raw.githubusercontent.com/Winowang/jupyter_gpu/master/jupyter_notebook_config.py && wget -P /home/inspur/image_components/jupyter_configure https://raw.githubusercontent.com/Winowang/jupyter_gpu/master/custom.js
# Copy the configuration file
mkdir /etc/jupyter && cp -rf /home/inspur/image_components/jupyter_configure/* /etc/jupyter

2. Ubuntu System

2.1 Installing Components via Dockerfile

2.1.1 Dockerfile Content

Dockerfile download link: https://github.com/wjyzzu/inpsur-dockerfile/tree/main/base/ubuntu

2.1.2 Build Steps

(1) Modify the base image in the FROM instruction as needed. It is recommended to upload the base image to AIStation in advance.
(2) After modifying the Dockerfile, upload it to your personal user directory.
(3) Create a new container image using the Image Management - Create feature. (4) Create a development environment based on the built image for testing.
(5) Note: The default Python version in the above Dockerfile is 3.6.11;
To specify a JupyterLab version, modify as shown in the following example:

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

2.2 Manual Component Installation

2.2.1 Online Installation

(1) Upload the base image to AIStation.
(2) Select a base container image to create a development environment. Refer to the above Dockerfile, execute the installation commands, and complete the component installation.
(3) Save the image.

2.2.2 Offline Installation

If the AIStation platform cannot connect to the external network, refer to the following methods:
(1) Download the relevant software packages or dependencies, upload them to the user directory, create a development environment based on the base image, perform offline component installation in the development environment, and finally save the image to complete the image build via the AIStation platform.
(2) Install components online in an environment with normal network connectivity, save them as a tar package using docker save, and import them into AIStation using the AIStation - Image Management - Internal Import feature.
The following describes how to download and install components:

2.2.2.1 Installing OpenSSH and OpenSSL

(1) Dependency package storage directory (Ubuntu offline installation package storage path; ignore for online installation)

/var/cache/apt/archives

(2) View dependency packages

apt-get update
apt-cache depends packname

(3) View installation package versions

sudo apt-cache madison openssh-client

(4) Download installation and dependency packages. Enter a clean container image.

Enter the Ubuntu image, remove unnecessary files in /var/cache/apt/archives, then download all dependency files. After downloading, copy them to your component directory /home/inspur/image_components/ubuntu18.04/openssh (Modify as needed)

apt-get install -d apt-cache depends openssh-server=1:7.2p2-4 | grep Depends | grep -v debconf-2.0 | cut -d: -f2 |tr -d "<>"

(5) Install OpenSSH and OpenSSL components

# Enter the directory
cd /home/inspur/image_components/ubuntu18.04/openssh
# Perform installation
dpkg -i *deb

(6) Fix installation dependency issues (execute if problems occur)

apt-get -f install

(7) OpenSSH configuration

# Create a new directory first; skip if it already exists
mkdir -p /run/sshd

# Execute ssh-keygen
/usr/bin/ssh-keygen -A
# Execute configuration:
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 -f /etc/ssh/ssh_config.new /etc/ssh/ssh_config && \
mv -f /etc/ssh/sshd_config.new /etc/ssh/sshd_config > /dev/null 2>&1;

2.2.2.2 Installing Jupyter

(1) Install Python 3

# Enter the clean image and download dependency packages
apt-get install -y build-essential libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev zlib1g-dev libsqlite3-dev
# Install all dependency packages:
cd /home/wjy/image_components/ubuntu18.04/python_depends
dpkg -i *deb
# Download the Python tgz package (version 3.7.6 below), extract it, and enter the directory
cd /home/wjy/image_components/python
wget https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tgz
tar -zxvf Python-3.7.6.tgz
cd Python-3.7.6
./configure
make && make install

# Modify configuration: mv /usr/bin/python /usr/bin/python27
mv /usr/bin/pip /usr/bin/pip27
ln -s /usr/local/bin/python3 /usr/bin/python
ln -s /usr/local/bin/pip3 /usr/bin/pip

(2) Install pip Offline installation:

# Download get-pip.py and install pip
cd /home/wjy/image_components
wget https://bootstrap.pypa.io/get-pip.py
# Install pip
python get-pip.py

(3) Install Jupyter

pip install jupyterlab (Online installation)
cd /home/inspur/image_components/jupyterlab # Enter this directory for offline installation; if the latest version is required, download the latest offline package online
pip3 install --no-index --find-links=/home/wjy/install_packages/jupyterlab jupyterlab-1.2.3-py2.py3-none-any.whl # Offline installation
jupyter lab --ip=0.0.0.0 --no-browser --allow-root # Run test to verify successful installation

(4) Jupyter configuration

# Offline configuration:
# Download configuration files: wget -P /home/inspur/image_components/jupyter_configure https://raw.githubusercontent.com/Winowang/jupyter_gpu/master/jupyter_notebook_config.py && wget -P /home/inspur/image_components/jupyter_configure https://raw.githubusercontent.com/Winowang/jupyter_gpu/master/custom.js
# Copy the configuration file
mkdir /etc/jupyter && cp -rf /home/inspur/image_components/jupyter_configure/* /etc/jupyter