3.5 容器使用

3.5.1 简述

​ Apptainer是目前在高性能计算平台上被大量应用的轻量虚拟化容器技术,能够提供操作系统级的虚拟化。 Hep_container是基于Apptainer容器管理命令开发的适用于高能所计算集群的容器客户端工具,满足用户使用多种操作系统版本及环境的需求。 说明:本文涉及的命令均需要在lxslc7登陆节点上运行,所用命令在以下目录,建议将该目录加入用户个人环境变量 PATH 中。

/cvmfs/container.ihep.ac.cn/bin/

3.5.2 命令说明

Hep_container的容器命令主要有三种操作images、shell、exec。可以在命令行中通过help参数查看各个命令的使用说明和样例

$ ./hep_container  help
Usage : ./hep_container  <command> [command options...]
CONTAINER USAGE COMMANDS:
    shell           Run a Bourne shell within container image
    exec            Execute a command within container image
    images          List Support container images
    groups          List Support groups
    -g groupname    With a specific group name
EXAMPLES:
    ./hep_container images
    ./hep_container groups

    ./hep_container shell SL5
    ./hep_container shell SL5 -g physics

    ./hep_container exec  SL5 cat /etc/redhat-release
    ./hep_container exec  SL5 python ./yourprograme.py
    ./hep_container exec  SL5 -g physics cat /etc/redhat-release

3.5.2.1 查看支持镜像

命令格式:hep_container images 该指令可以查看当前提供的操作系统容器镜像。

$ hep_container images
Hep_container support images:
        SL5 : Scientific Linux 5
        SL6 : Scientific Linux 6
        SL7 : Scientific Linux 7

3.5.2.2 查看支持用户组/实验组

命令格式:hep_container groups 该指令可以查看容器命令当前支持提供的用户组或者实验组。通过 -g 参数指定用户组或实验组,容器内会挂载对应用户目录和实验目录。不指定-g参数默认采用主组作为用户组或实验组。

$ hep_container groups
Hep_container support groups:
  u07|atlas|atlasrun|comet|offline|physics|higgs|ams|cms|dyw|hxmt|polars|juno|argo|lhaaso|

3.5.2.3 进入容器环境

命令格式:hep_container shell [container image] 该指令可以在容器内启动一个shell,因此可以在容器外部与容器内部进行交互操作。运行exit则可以退出该shell。 下例为运行启动一个SL5操作系统镜像后,用户当前为SL5的系统环境.

$ hep_container shell SL5
Apptainer: Invoking an interactive shell within container...
Apptainer> cat /etc/redhat-release
Scientific Linux SL release 5.5 (Boron)
Apptainery> exit
exit

3.5.2.4 容器内执行命令

命令格式:hep_container exec [container image] [command] 该指令可以在外部主机上将指定的command运行在指定的容器内。 下例为在lxslc7上以SL5的环境运行SL5命令,并得到结果。

$ hep_container exec SL5 cat /etc/redhat-release
Scientific Linux SL release 5.5 (Boron)

3.5.2.5 组参数

不同实验组的用户进入到容器会挂载对应实验的数据盘。 如果不指定-g 组参数,默认挂载所属主组实验的数据盘。-g 可以加一个组或多个组,多组以:隔开 查看自己的组信息。第一个gid一般为主组

[user@lxslc705 ~]$ id liming
uid=60020(liming) gid=600(u07) groups=600(u07),290(physics),1004(juno)
hep_container shell SL5 -g physics
hep_container shell SL6 -g juno:dyw

3.5.3 说明

由于AFS 口令认证版本问题,在lxslc7上暂时无法实现登录同时获得afs的tokens,如果用户登录lxslc7后,出现类似以下报错 mkdir: cannot create directory '/afs/ihep.ac.cn/users/z/zhengw/.Xauthority': Permission denied 请先运行:klog 再执行容器的各种命令。

results matching ""

    No results matching ""