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
    

Bug Catching

Buggy Content

Bug Description

Submit As Issue

It's a little complicated....

I'd like to ask someone.

PR

Just a small problem.

I can fix it online!

Bug Type
Specifications and Common Mistakes

● Misspellings or punctuation mistakes;

● Incorrect links, empty cells, or wrong formats;

● Chinese characters in English context;

● Minor inconsistencies between the UI and descriptions;

● Low writing fluency that does not affect understanding;

● Incorrect version numbers, including software package names and version numbers on the UI.

Usability

● Incorrect or missing key steps;

● Missing prerequisites or precautions;

● Ambiguous figures, tables, or texts;

● Unclear logic, such as missing classifications, items, and steps.

Correctness

● Technical principles, function descriptions, or specifications inconsistent with those of the software;

● Incorrect schematic or architecture diagrams;

● Incorrect commands or command parameters;

● Incorrect code;

● Commands inconsistent with the functions;

● Wrong screenshots.

Risk Warnings

● Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

● Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions;

● Copyright infringement.

How satisfied are you with this document

Not satisfied at all
Very satisfied
Submit
Click to create an issue. An issue template will be automatically generated based on your feedback.