Stop docker container from alpine image
You cannot stop the docker image this way.
Firstly, if it poweroff
had to function (and it was in the past, due to a problem ), it would stop the entire computer, because of how the binary works poweroff
, and the power-stop mechanic is designed on Linux and hardware.
What needs to be done to properly stop your container is to exit the entry point ( exit
in the shell) or send a signal to this process (for example: docker stop
send SIGTERM
to the current entry point before killing it after the grace period).
If you really want to unplug the host from the container (why would you ever want to do that?), You can enable the option --privileged
to give all the power to your root in the container, then do:
echo 1 > /proc/sys/kernel/sysrq; echo o > /proc/sysrq-trigger
Be careful, this will really stop the master and is brutal. Writing 1
to sysrq
activates kernel functions sysrq
, which allows keyboard requests to the kernel using the SysRq key , but also through a file sysrq-trigger
. o
means poweroff.
source to share