Docker Community Forums

Share and learn in the Docker community.

Container with --restart=always goes away (CoreOS), 'docker ps' brings back

(Gh2k) #1

I’m new to docker, sorry if this is a FAQ. I’m running CoreOS alpha 1214.0.0 on a dev server. I’ve run two conainers that I’d like to keep running, and started them with docker run --restart=always blah. This results in the docker host listening on ports 80 and 443, which is what I want.

After some time (unsure how long, but reliably “tomorrow”) the containers have stopped running. Docker host is no longer listening on those ports.

Running docker ps shows the two containers as running, with status ‘up less than a second’, so it appears that running this command has “woken up” the containers. Sure enough, after running docker ps the host starts listening on those ports again and everything is fine. See:

CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS                  PORTS                                      NAMES
0dc41bdb95f4        gh2k/xen-orchestra:latest   "/usr/bin/supervisord"   10 days ago         Up Less than a second   80/tcp                                     xen-orchestra
9c0b4921e49d        jwilder/nginx-proxy         "/app/docker-entrypoi"   12 days ago         Up Less than a second>80/tcp,>443/tcp   nginx-proxy

What am I doing wrong?

(Gh2k) #2

As this has gone for a week without any replies, I’m wondering if I should try asking somewhere else - or if anyone could point me at some resources on how I could diagnose this issue in more depth? I’m not sure where to go next.

(Ktwalrus) #3

I’m seeing the same thing. After reboot, my containers aren’t restarted until I ssh in and do a docker ps. Probably a problem with CoreOS which has de-emphasized Docker support in favor of Kubernetes w/ Rocket installation for containers.

Could also be an OpenStack/CoreOS problem? Are you also running CoreOS in a VM?

(Ktwalrus) #4

I posted about this in the CoreOS Google Group and they got back to me with the answer.

You have to enable Docker on reboot by issuing:

$ sudo systemctl enable docker.service


(Gh2k) #5

Awesome, thanks :slight_smile: I’ll try that! Seems weird that docker isn’t enabled by default on coreos!

I did some more reading and it looks like creating systemd units for the containers I want to run is preferred over --restart=always so I’m going to do that instead. I think that lets me use journalctl to see the container logs, although I can get those with ‘docker logs’ anyway. I haven’t decided which is easier.