Rancher exited after host machine power off and reboot - docker

Can someone explain me why after host machine reboot all containers are exited?How can i find a way to restart containers specially rancher containers and everything be as before?

You can use the docker restart policy to control container automatic startup. Check Start containers automatically for more info.
As for the current container that are stopped you need to start them manually:
docker ps -a
docker start <container>

Related

how to know which docker container, image was ON before server got shut down

I have a server in which the docker containers were running. Server got shutdown. How to know which container was on; Because container list are empty now.
Run this command to see whats container is running :
docker ps
To see all containers whaterver it doesnot running or is up:
docker ps -a
And check time container went down.
Bring it up :
docker start container_id
Found out that there where no containers started. If it where, the containers would of been stopped.

Docker Container restart after VM reboot

we have deployed docker container and the restart policy is --restart unless-stopped. This will start the container after VM reboot. The docker service is also enabled to start the service after reboot.
The problem is whenever reboot happen, the list of containers and images all are gone. Solution for this is to restart the docker service. so after this container is coming up.
so question is why do we need to restart the docker service even after it is enabled to start after reboot?
appreciate help on this?
I don't know the truly internals of Docker Engine, but I make my assumptions:
On Virtual Machine (or native host) restart, the docker engine is stopped, so the containers receive a "stop" signal too (in background a systemctl stop docker will be performed)
What you are doing with systemctl restart docker (or similar command) is sending a "restart" signal to the docker engine, not a "stop" one.
You should use --restart always if you want to be sure that the containers are restarted automatically when the VM is freshly started/restarted.

Docker ps disappeared after restart system

Run docker container on a Linux system. From docker ps can see all the processes.
After restart the system and run docker ps can't see some containers, but use docker ps -a can see them. Is the container still running?
If you don't set the option --restart=always when run the docker container, these containers will not be started automatically, after you restart the system.
Restart policies (–restart)
always - Always restart the container regardless of the exit status. When you specify always, the Docker daemon will try to restart the container indefinitely. The container will also always start on daemon startup, regardless of the current state of the container.
Refer: docker run - Restart policies (–restart)

How do we set docker containers to restart on reboot and on-failure?

I would like the docker containers to come up
On host reboot or when docker is restarted on host
On failure with maximum retries .
I am aware that the docker restart policies unless-stopped and always are in the same direction but I would want them to fail after maximum retries.
Thinking of below steps as a solution
No restart policy on docker containers
systemd-docker to restart containers on-failure and enabled on reboot.
is there a better way to do this?
I would like the docker containers to come up On host reboot or when docker is restarted on host
This is not a complete answer, but know that docker 1.12 will add a daemonless container mode
(PR 23213):
Daemonless Containers
Starting with Docker 1.12 containers can run without Docker or containerd running.
This allows the Docker daemon to exit, be upgraded, or recover from a crash without affecting running containers on the system.
To enable this functionality you need to add the --live-restore flag when launching dockerd. This will ensure that Docker does not kill containers on graceful shutdown or on restart leaving the containers running.

Are docker containers destroyed when machine is restarted?

I was having a network issue, so I restarted my local machine, which also aborted my docker default VM. So I ran the below command to restart my virtualbox instance docker-machine restart default.
I previously had built containers on default, but I want to know, do I need to rebuild those same containers now that I restarted default, or can I just run docker-compose up?
They are not destroyed. They are stopped though. You can check with
docker ps -a
This will show all containers, stopped and running. In order to start a container
docker start <container name or container id>

Resources