# Rebooting the host from within a User container

**URL:** <https://forums.suse.com/t/rebooting-the-host-from-within-a-user-container/9126>\
**Category:** RancherOS\
**Created:** [February 6, 2018, 10:43am UTC](https://forums.suse.com/t/rebooting-the-host-from-within-a-user-container/9126 "2018-02-06T10:43:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cron410](https://avatars.discourse-cdn.com/v4/letter/c/71c47a/32.png) [@cron410](https://forums.suse.com/u/cron410)\
**Post date:** [February 6, 2018, 10:43am UTC](https://forums.suse.com/t/rebooting-the-host-from-within-a-user-container/9126/1 "2018-02-06T10:43:57Z")

</div>

I have a test farm set up with a few rancherOS hosts that are destroyed and PXE booted after running tests. It would be nice to be able to reboot the host from a user container. So far I have found multiple posts around the internet that achieve this by mounting systemd as a volume and telling the host’s systemd to kick off the reboot process. I also found someone using magic sysrq to perform the reboot, but I want something that has a smaller risk of being fixed in Docker or RancherOS in the future and breaking my workflow for these disposable hosts. Discussion on magic sysrq -\> [https://stackoverflow.com/questions/24750137/restarting-host-from-docker-container](https://stackoverflow.com/questions/24750137/restarting-host-from-docker-container)

What is the preferred way to reboot the host from within a user docker container on a clean RancherOS machine?

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [February 6, 2018, 7:15pm UTC](https://forums.suse.com/t/rebooting-the-host-from-within-a-user-container/9126/2 "2018-02-06T19:15:01Z")

</div>

I would add a script to the host that

- (deletes the file from the next step on startup)
- watches for a certain file in a specific directory to exist
- maybe does other useful cleanup tasks
- calls regular reboot

Then bind mount in that directory to your container and touch the file when you want a reboot. (for RancherOS, write\_files and start it in rc.local or similar). That way you’re not relying on any particular host distro, kernel params, etc to trigger it.
