Reboot or Shutdown in a Container

Function Description

The reboot and shutdown commands can be executed in a system container. You can run the reboot command to restart a container, and run the shutdown command to stop a container.

Parameter Description

Command

Parameter

Value Description

isula create/run

--restart

  • Variable of the string type.
  • Supported option is as follows:

    on-reboot: restarts the system container.

      

Constraints

  • The shutdown function relies on the actual OS of the container running environment.
  • When you run the shutdown -h now command to shut down the system, do not open multiple consoles. For example, if you run the isula run -ti command to open a console and run the isula attach command for the container in another host bash, another console is opened. In this case, the shutdown command fails to be executed.

Example

  • Specify the –restart on-reboot parameter when starting a container. For example:

    [root@localhost ~]# isula run -tid --restart on-reboot --system-container --external-rootfs /root/myrootfs none init
    106faae22a926e22c828a0f2b63cf5c46e5d5986ea8a5b26de81390d0ed9714f
    
  • In the container, run the reboot command.

    [root@localhost ~]# isula exec -it 10 bash
    [root@localhost /]# reboot
    

    Check whether the container is restarted.

    [root@localhost ~]# isula exec -it 10 ps aux
    USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
    root         1  0.1  0.0  21588  9504 ?        Ss   12:11   0:00 init
    root        14  0.1  0.0  27024  9376 ?        Ss   12:11   0:00 /usr/lib/system
    root        17  0.0  0.0  18700  5876 ?        Ss   12:11   0:00 /usr/lib/system
    dbus        22  0.0  0.0   9048  3624 ?        Ss   12:11   0:00 /usr/bin/dbus-d
    root        26  0.0  0.0   8092  3012 ?        Rs+  12:13   0:00 ps aux
    
  • In the container, run the shutdown command.

    [root@localhost ~]# isula exec -it 10 bash
    [root@localhost /]# shutdown -h now
    [root@localhost /]# [root@localhost ~]#
    

    Check whether the container is stopped.

    [root@localhost ~]# isula exec -it 10 bash
    Error response from daemon: Exec container error;Container is not running:106faae22a926e22c828a0f2b63cf5c46e5d5986ea8a5b26de81390d0ed9714f
    

有奖捉虫

“有虫”文档片段

存在的问题

提交类型 issue
有点复杂...
找人问问吧。
PR
小问题,全程线上修改...
一键搞定!
问题类型
规范和低错类

● 错别字或拼写错误;标点符号使用错误;

● 链接错误、空单元格、格式错误;

● 英文中包含中文字符;

● 界面和描述不一致,但不影响操作;

● 表述不通顺,但不影响理解;

● 版本号不匹配:如软件包名称、界面版本号;

易用性

● 关键步骤错误或缺失,无法指导用户完成任务;

● 缺少必要的前提条件、注意事项等;

● 图形、表格、文字等晦涩难懂;

● 逻辑不清晰,该分类、分项、分步骤的没有给出;

正确性

● 技术原理、功能、规格等描述和软件不一致,存在错误;

● 原理图、架构图等存在错误;

● 命令、命令参数等错误;

● 代码片段错误;

● 命令无法完成对应功能;

● 界面错误,无法指导操作;

风险提示

● 对重要数据或系统存在风险的操作,缺少安全提示;

内容合规

● 违反法律法规,涉及政治、领土主权等敏感词;

● 内容侵权;

您对文档的总体满意度

非常不满意
非常满意
创Issue赢奖品
根据您的反馈,会自动生成issue模板。您只需点击按钮,创建issue即可。