-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
restart container after reboot #872
Comments
What version of Docker are you running? Perhaps add the output of |
It was a Digital Ocean's droplet. I'll make another try tomorrow. |
Thanks for adding that info; some distros still have older versions of Docker (pre 1.2) and the restart-policies were introduced with Docker 1.2 :) |
I can reproduce this with Compose 1.1.0-rc1 and Docker 1.4.1 on Ubuntu 14.04 under certain conditions that I do not understand yet: Using a real world example, the containers will come up after restarting the docker service, but they will not come up after rebooting the host. After a reboot, the manually started services lost their restarting characteristics as well:
But this behavior depends on service composition.
|
@albers wondering if you is the restart-policy stripped from the containers after restart? (Sorry, don't have a host at hand here myself that I can restart) |
Can you reproduce this without Compose? i.e. with |
@thaJeztah At all stages, the output of
|
@albers thanks, I was wondering if Fig/Compose would strip the RestartPolicy somehow during the re-create steps. |
@aanand I manually created the application stack like this:
My findings:
Looks like a Docker issue. |
Dokku presentation video around minute 7 has a good way of handling zero-downtime deployment |
it works for me on CentOS 7 my docker-compose.yml:
I rebooted the VM in openstack and after the services where started up correctly: [root@swarm01 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
894fadbf5591 nginx:latest "nginx -g 'daemon of 6 minutes ago Up 4 minutes 443/tcp, 0.0.0.0:80->80/tcp web_web_1
42eacd5cb050 google/cadvisor:0.10.1 "/usr/bin/cadvisor" 6 minutes ago Up 4 minutes 8080/tcp web_cadvisor_1 I than killed nginx process manually, and it was restarted automatically. nice. [root@swarm01 ~]# ps aux | grep nginx
root 1971 0.0 0.0 30964 2948 ? Ss 11:52 0:00 nginx: master process nginx -g daemon off;
101 2004 0.0 0.0 31940 2588 ? S 11:52 0:00 nginx: worker process
root 2041 0.0 0.0 112640 976 pts/0 S+ 11:56 0:00 grep --color=auto nginx
[root@swarm01 ~]# kill 1971
[root@swarm01 ~]# ps aux | grep nginx
root 2063 1.0 0.0 30964 2944 ? Ss 11:57 0:00 nginx: master process nginx -g daemon off;
101 2073 0.0 0.0 31940 2520 ? S 11:57 0:00 nginx: worker process
root 2093 0.0 0.0 112640 972 pts/0 S+ 11:57 0:00 grep --color=auto nginx
[root@swarm01 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
894fadbf5591 nginx:latest "nginx -g 'daemon of 7 minutes ago Up 9 seconds 443/tcp, 0.0.0.0:80->80/tcp web_web_1
42eacd5cb050 google/cadvisor:0.10.1 "/usr/bin/cadvisor" 7 minutes ago Up 5 minutes 8080/tcp web_cadvisor_1 On the other hand If I use the docker CLI to stop nginx, it will not be restarted automatically. Looks logic to me, because of course using the docker CLI is an intentional stop. [root@swarm01 ~]# docker stop 894fadbf5591
894fadbf5591
[root@swarm01 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
42eacd5cb050 google/cadvisor:0.10.1 "/usr/bin/cadvisor" 16 minutes ago Up 13 minutes 8080/tcp web_cadvisor_1 the same apply if we use docker-compose CLI commands, if we stop a service intentionally, it will not be autorestarted. [root@swarm01 web]# docker-compose ps
Name Command State Ports
---------------------------------------------------------------------------
web_cadvisor_1 /usr/bin/cadvisor Up 8080/tcp
web_web_1 nginx -g daemon off; Up 443/tcp, 0.0.0.0:80->80/tcp
[root@swarm01 web]# docker inspect -f "{{ .HostConfig.RestartPolicy }}" web_web_1
map[MaximumRetryCount:0 Name:always]
[root@swarm01 web]# docker-compose stop web
Stopping web_web_1...
[root@swarm01 web]# docker-compose ps
Name Command State Ports
---------------------------------------------------------
web_cadvisor_1 /usr/bin/cadvisor Up 8080/tcp
web_web_1 nginx -g daemon off; Exit 0 So far so good in my case scenario. |
use docker restart policies https://docs.docker.com/reference/commandline/cli/#restart-policies They work in our setup, see tests docker/compose#872 (comment)
use docker restart policies https://docs.docker.com/reference/commandline/cli/#restart-policies They work in our setup, see tests docker/compose#872 (comment)
+1 The same DigitalOcean droplet created with Docker Machine docker inspect -f "{{ .HostConfig.RestartPolicy }}" containerId
I should add that Upstart kept this daemon up for years on the came DigitalOcean/Ubuntu/Rails before I switched to Docker. |
+1 Docker version 1.6.1, build a8a31ef/1.6.1 After reboot docker start failed: |
I think this is ultimately a docker engine bug. After compose starts the containers it's up to engine to restart them. |
@dnephin agreed; also, All Docker versions reported here are now getting old; this issue could be resolved now, but hard to tell without, e.g. daemon logs |
Works for me here with Docker 1.7.1, Compose 1.4.0, on CoreOS 766.3.0. |
Sounds like this was not a compose issue, and has been fixed in engine |
I'm having this exact problem with Docker on Windows. I'm using nextcloud with docker-compose. If I |
Hi, I am having the same problem with ubuntu 19.04. |
Issue also ocurring on Windows Server 2019: Reboot of host does not start up containers. |
Issue with |
@kustrun I got same trouble with Docker version 18.09.7 on Ubuntu 18.04. But I solved this problem with sudo systemctl enable docker. I just missed to enable docker service autostart... |
Same here. Windows Server 2019. Rebooting machine does not start up containers. ps -a shows containers still there but stopped. |
Same issues here. Windows server 2019. I am not sure why issue is closed |
Update for me I had to do couple of things, switch the docker-compose file to 2.2 so that restart will work on compose mode. Secondly I realized when machines when host is rebooted, the old network deleted but the the containers try to use that and fail. The right way to do it was define a network and let it get created then machines come back online no issues |
@shakeelosmani Tried what you said but still my containers refuse to start. I define a network and have the containers use it, everything starts up and shuts down OK but stay in "exited" on a reboot. This is on Docker for Windows which I think has some issues with this. |
Hi people,
I'm trying docker-compose 1.10-rc1 on Fedora 21.
But after a simple # reboot containers don't start again.
Maybe I miss something ?
The text was updated successfully, but these errors were encountered: