Best way to restart Rancher-Server?

Set up
I have got Rancher Server to work on a recent installation of Ubuntu 16.04 on my laptop. I am experimenting with Rancher to manage making some new Docker images to use for local development at the moment. I am using the laptop as the host with its external IP address on the LAN as the host IP address.

As this is a laptop, I am wanting to turn it off every evening.

What is the best way to turn off and restart Rancher-Server in my set up?
So far I have tried a few tactics.

  1. Stopping all the Docker images
    I have closed the Rancher GUI and then stopped all the Docker containers for Rancher, both the server one and the ones related to the host, which is my laptop.

On restarting Rancher Server, I have then restarted the nine or so containers related to the laptop as host. I have found they have not all restarted at once. After some further restarting of the containers which have exited soon after I attempted to restart them, I have eventually got the host back up. For the most part this works, but it is quite a tedious process.

  1. Simply closing down the laptop
    Once I think I left the Rancher containers running and simply switched the laptop off. When I switched it back on, Rancher Server restarted itself, and to my surprise, this seemed to work quite well, and the host has been picked up too. However I am uncomfortable with doing this.

  2. Removing Host containers and adding the host back
    I have also tried stopping and deleting all the host containers, after first stopping the Rancher Server.

A few minutes after restarting Rancher Server, I have added the laptop as a new host (again), running the command line script on the second of the two ‘Add host’ pages. This has added the host back in really quite quickly, and so in some ways I have preferred this method.

The problem with this method for restarting, though, is that any container I have built in Rancher, though it has appeared momentarily, has then been deleted and I have lost it. That’s a shame, because that’s one of the main benefits of using Rancher in my testing ground scenario. The containers I have built from the Docker CLI are fine - they persist and are picked up by the host laptop quite quickly.

So my questions are:
a) What’s the best way for me to stop Rancher-Server and my laptop as host?
b) What’s the best way for me to restart Rancher-Server, without losing containers and stacks I have built using the Rancher interface?

Many thanks.

Shortly after posting this, I found what seemed like a clean repeatable way to do this.

a) Stopping Rancher-Server
I simply closed the Rancher management web page, and closed all the running containers. The simple way to do this was
$ docker stop $(docker ps -q)
Clearly in my case I wanted to stop all my running containers, and you would need to adapt this if you only wanted to stop some of them.

b) Restarting Rancher
When I restart my laptop, one Rancher container starts up; its image name is “rancher/agent:v1.2.5” and its name is “rancher agent”. It seems that this one starts on its own.
All I have to do to get Rancher running with all the settings I had before is to restart rancher server:
$ docker ps -a // to display all Docker containers, including stopped ones.
$ docker restart <first few characters of rancher server container>
I tend to wait a couple of minutes, then open the Rancher management web page. The other Rancher host containers don’t start up until I do this. Then under (INFRASTRUCTURE | Hosts) I see the host listed as ACTIVE with all parts showing as healthy. Looking back at the command line, I see that all the Rancher containers for the host have started up. I have to individually restart other containers, which is fine in my testing environment.

I have made it a little easier by renaming the Rancher containers to be more clearly identifiable (starting “r-” in my case).

This process of restarting works well when I am on the same LAN and my laptop is assigned the same IP address.

Otherwise I would have to delete containers and run the Rancher server from scratch. e.g.:
$ sudo docker run -d --restart=unless-stopped -p 8080:8080 rancher/server:latest
I might lose the containers I made within Rancher, but I haven’t tested it recently.

I hope this might help others experiment with Rancher on their laptops.

for me the best was service docker restart, I have rancher running as a daemon

Running Rancher through Docker, the best way for me was:

service docker restart

All the containers and namespaces were still there after the restart.

Also it solved a problem for me regarding a node, that was NotReady.