Skip to content
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

New containers created every reboot #1505

Closed
bobvanderlinden opened this issue Sep 25, 2015 · 57 comments · Fixed by #1591
Closed

New containers created every reboot #1505

bobvanderlinden opened this issue Sep 25, 2015 · 57 comments · Fixed by #1591

Comments

@bobvanderlinden
Copy link

Description of problem:

A new docker container is created every time I reboot the machine for Dokku apps.

Output of the following commands

  • dokku version:
v0.4.0
  • dokku plugins:
 !     `plugins` is not a dokku command.
 !     See `dokku help` for a list of available commands.
  • docker version:
Client:
 Version:      1.8.2
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   0a8c2e3
 Built:        Thu Sep 10 19:19:00 UTC 2015
 OS/Arch:      linux/amd64

Server:
 Version:      1.8.2
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   0a8c2e3
 Built:        Thu Sep 10 19:19:00 UTC 2015
 OS/Arch:      linux/amd64
  • docker info:
Containers: 5
Images: 9
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 19
 Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.19.0-25-generic
Operating System: Ubuntu 14.04.3 LTS
CPUs: 1
Total Memory: 993.2 MiB
Name: dokku
ID: F5XJ:RPWM:PSSQ:OY32:XEHY:TQ6C:YYJQ:K4WG:O4SP:QUA7:63LM:JNHQ
WARNING: No swap limit support
  • uname -a:
Linux dokku 3.19.0-25-generic #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Environment details (AWS, VirtualBox, physical, etc.):

Running Dokku on a clean VirtualBox machine with a clean Ubuntu Server 14.04.3 LTS install.
How was dokku installed?:

$ history
    1  sudo apt-get update
    2  sudo apt-get upgrade
    3  wget https://raw.github.com/progrium/dokku/v0.4.0/bootstrap.sh
    4  sudo DOKKU_TAG=v0.4.0 bash bootstrap.sh
    5  sudo sshcommand acl-add dokku bob
        ...

How reproducible:
I just did this a second time to make sure it wasn't some mistake:

  • Create a new virtual machine in VirtualBox.
  • Install Ubuntu Server 14.04.3 LTS with OpenSSH server.
  • Run commands above to update/upgrade and install dokku.
  • Push NodeJS application to dokku@dokku.local:cycle-remote
  • Check sudo docker ps and verify one container is running.
  • sudo reboot
  • Check sudo docker ps again and notice there are 2 containers running.

Actual Results:

More reboots results in more running containers!

Expected Results:

The same container that was initially started should be running after rebooting.

Additional info:

I did notice that no web-based installer was started nor was it available on http://dokku.local/. http://dokku.local/ only showed the default nginx page after installing Dokku.

Additionally after pushing my app to cycle-remote (or cycleremote) I couldn't access the app through http://cycle-remote.dokku.local/ or http://cycle-remote.dokku.local/. I noticed NO_VHOST was set to 1, so I used dokku config:unset cycle-remote NO_VHOST. This still did not bring up the mentioned urls. Only after issueing dokku domains:add cycle-remote cycle-remote.dokku.local did the url come up. I presume this is unrelated to the issue I'm submitting, but I thought I'd mention this.

@ghost
Copy link

ghost commented Sep 26, 2015

Also experienced multiple containers on reboot, but everything else works great for me

@RavenXce
Copy link

Experienced multiple containers on dokku ps:restart after upgrading to dokku 0.4.0, unsure if it's related.

@bobvanderlinden
Copy link
Author

@RavenXce Indeed, I see the same thing.

@michaelshobbs
Copy link
Member

@RavenXce dokku ps:restart will yield another container temporarily due to the way zero-downtime deployments work.

@bobvanderlinden i am unable to recreate this. can you confirm that the running containers remain running for more than a few minutes after boot? can you include a docker ps here? also, the plugin listing command changed in 0.4.x. (i've updated the docs) please include dokku plugins as well.

i'd like to see what how dokku has configured nginx. can you include the nginx.conf for your app as well as the output from docker inspect for each of the running app containers. hopefully we'll find the root cause in that info.

@bobvanderlinden
Copy link
Author

@michaelshobbs No it doesn't go away after a number of minutes (checked after 2 hours).

I rebooted again and ran docker ps:

$ sudo docker ps
CONTAINER ID        IMAGE                       COMMAND             CREATED              STATUS              PORTS                     NAMES
abac8e6ecee0        dokku/cycle-remote:latest   "/start web"        About a minute ago   Up About a minute                             berserk_davinci
caea9e6dd3e9        dokku/cycle-remote:latest   "/start web"        4 days ago           Up About a minute                             cocky_babbage
cd45293bed6d        dokku/cycle-remote:latest   "/start web"        4 days ago           Up About a minute                             backstabbing_goldstine
4801de34acc8        dokku/cycle-remote:latest   "/start web"        4 days ago           Up About a minute                             nostalgic_stallman
41673646c5ea        dokku/cycle-remote:latest   "/start web"        4 days ago           Up About a minute   0.0.0.0:32769->5000/tcp   boring_bell
ee2e8ad8fadd        dokku/cycleremote:latest    "/start web"        4 days ago           Up About a minute   0.0.0.0:32768->5000/tcp   sleepy_tesla

What is interesting is that I've stopped cycleremote before rebooting using dokku ps:stop cycleremote. After rebooting it was running again.

Here is the listing of plugins:

$ dokku plugin
  00_dokku-standard    0.4.0 enabled    dokku core standard plugin
  20_events            0.4.0 enabled    dokku core events logging plugin
  apps                 0.4.0 enabled    dokku core apps plugin
  backup               0.4.0 enabled    dokku core backup plugin
  build-env            0.4.0 enabled    dokku core build-env plugin
  certs                0.4.0 enabled    dokku core certificate management plugin
  checks               0.4.0 enabled    dokku core checks plugin
  common               0.4.0 enabled    dokku core common plugin
  config               0.4.0 enabled    dokku core config plugin
  docker-options       0.4.0 enabled    dokku core docker-options plugin
  domains              0.4.0 enabled    dokku core domains plugin
  enter                0.4.0 enabled    dokku core enter plugin
  git                  0.4.0 enabled    dokku core git plugin
  nginx-vhosts         0.4.0 enabled    dokku core nginx-vhosts plugin
  plugin               0.4.0 enabled    dokku core plugin plugin
  ps                   0.4.0 enabled    dokku core ps plugin
  shell                0.4.0 enabled    dokku core shell plugin
  tags                 0.4.0 enabled    dokku core tags plugin
  tar                  0.4.0 enabled    dokku core tar plugin

As stated earlier dokku ps:restart is probably the problem. I also found out that dokku ps:stop and dokku ps:start act like they should (no 'zombie-docker-processes').

I've looked in the code going through the code of Dokku it seems the problem is around this statement:
https://github.com/progrium/dokku/blob/master/plugins/ps/commands#L73

It seemed it doesn't actually stop the app, as that statement is the same as ps:start does. I'm going to try to fix it here and make a PR when it works correctly.

@michaelshobbs
Copy link
Member

The current implementation preserves zero-downtime deployment. Calling ps:stop would defeat that effect. More likely there is an issue with the subshell spawned that is responsible for stopping the previous container.

@michaelshobbs
Copy link
Member

I'm seeing the expected behavior below. I have seen this behavior on hosts with limited free memory.

root@dokku:~# dokku apps && docker ps && dokku ps:restartall && docker ps && sleep 90 && docker ps
=====> My Apps
node-js-app
CONTAINER ID        IMAGE                      COMMAND             CREATED             STATUS              PORTS               NAMES
75fe508f66ad        dokku/node-js-app:latest   "/start web"        4 minutes ago       Up 4 minutes                            sleepy_mcclintock
-----> Releasing node-js-app (dokku/node-js-app:latest)...
-----> Deploying node-js-app (dokku/node-js-app:latest)...
-----> DOKKU_SCALE file found
=====> # test comment
=====> web=1
=====> worker=0
-----> Running pre-flight checks
-----> Attempt 1/5 Waiting for 5 seconds ...
       CHECKS expected result:
       http://localhost/ => "Hello World!"
-----> All checks successful!
=====> node-js-app container output:
       Node app is running at localhost:5000
=====> end node-js-app container output
-----> Running post-deploy
-----> Configuring node-js-app.dokku.me...
-----> Creating http nginx.conf
-----> Running nginx-pre-reload
       Reloading nginx
-----> Shutting down old containers in 60 seconds
=====> 75fe508f66ad4ba3000b3c3c62cc1fe22218bfcd8b07f9f9538e42b6838b5c14
=====> Application deployed:
       http://node-js-app.dokku.me

CONTAINER ID        IMAGE                      COMMAND             CREATED             STATUS              PORTS               NAMES
e142655fd30f        dokku/node-js-app:latest   "/start web"        6 seconds ago       Up 5 seconds                            elated_yonath
75fe508f66ad        dokku/node-js-app:latest   "/start web"        4 minutes ago       Up 4 minutes                            sleepy_mcclintock
CONTAINER ID        IMAGE                      COMMAND             CREATED              STATUS              PORTS               NAMES
e142655fd30f        dokku/node-js-app:latest   "/start web"        About a minute ago   Up About a minute                       elated_yonath
root@dokku:~#

@ghost
Copy link

ghost commented Oct 1, 2015

Old containers are stopped after 60 seconds using ps:restart but rebooting the server will start a lot of containers and won't stop them after 60 seconds.

Ps I have 8g of ram, only ever using 1g at any time.

@michaelshobbs
Copy link
Member

@josegonzalez related to the restart policy perhaps?

@josegonzalez
Copy link
Member

Yeah that's what I'm thinking. On boot, containers should start through docker. Maybe worth disabling the reboot ps command and seeing what happens?

@bobvanderlinden
Copy link
Author

I'll give that a try.

@bobvanderlinden
Copy link
Author

Ok, just gave this a try. I had a bunch of 'zombie' docker processes from a dokku app. I stopped them all (sudo docker stop {ID}). I removed /etc/init/dokku-redeploy.conf and rebooted.

Surprisingly all stopped processes were there after rebooting (same IDs). I'm not sure whether Dokku misconfigured the docker instances or whether this is a docker problem of itself.

@josegonzalez
Copy link
Member

The processes get started again after reboot due to our --restart=on-failure=X flag usage maybe?

@bobvanderlinden
Copy link
Author

@josegonzalez Indeed! It seems this is a docker problem: moby/moby#11008

The issue was fixed due to moby/moby#15348, which adds --restart=unless-stopped. It doesn't seem like it has the same semantics as on-failure=x, but it probably will solve the problem. I'll give it a try.

@josegonzalez
Copy link
Member

That's annoying. Can you see if there is an issue giving it the on-failure=x type of recovery?

@bobvanderlinden
Copy link
Author

I haven't found anything, so I asked here: moby/moby#15348 (comment)

Also, this option is only available in the master branch of docker, not in any of the stable versions. Kind of a bummer.
Maybe slightly dirty, but does it make sense to remove old containers once they are cleanly stopped after a restart? (docker rm ...)

@michaelshobbs
Copy link
Member

That wouldn't be my first preference. Perhaps we should rollback the --on-restart policy until it's stabilized?

@josegonzalez
Copy link
Member

Yeah thats my thinking here. While I like being able to support that functionality, I also like having fewer known bugs.

@josegonzalez
Copy link
Member

Needs to be a manual revert of #1475 and #1473 so as not to break things.

@bobvanderlinden
Copy link
Author

The restart on failure could potentially be handled inside the container. Not ideal, but people might be able to use that to get the restart-policy behavior back.

That said, dokku ps:restartall will still start all apps upon booting. It still leaves the problem that stopped apps will be started upon boot. I think this will be solved 'automatically' once docker has the fixes (and hopefully combined with on-failure) in place.

@josegonzalez
Copy link
Member

We could just stop all apps on boot and reboot?

@michaelshobbs
Copy link
Member

I don't think that will solve the issue. We currently only store the container id of last known successfully started container.

https://github.com/progrium/dokku/blob/07e94de20513c1e274466a09a486dd7884839ee5/dokku#L151

@bobvanderlinden
Copy link
Author

@josegonzalez That's also far from preferable for production. Reboots will happen (planned or not). Manual intervention (starting all apps) shouldn't be needed after an unplanned reboot.

Docker solves this problem, as it already automatically starts containers upon boot if they were running before the reboot. When Docker fixes the issue, dokku doesn't need to do anything at boot (no ps:restartall). I think everything will just work.

However, as docker hasn't released the fix yet, Dokku needs to work around this. The problem at the moment is that containers from older versions of an app (after rebuilds/restarts) that were stopped by dokku are all started upon boot by docker. The way to make sure Docker doesn't start these containers at this time is by removing them. That way old containers (previous versions of an app) will be deleted from disk. Docker will not start them and only the latest containers/versions of apps will be left. At least, that's what I've found to be a way to make things work correctly. I'm not sure whether this has other side-effects.

@KernelMadness
Copy link
Contributor

Experiencing same problems.
After reboot we have old containers up along with new ones.

@michaelshobbs
Copy link
Member

I still can't reproduce this in my vagrant environment. Any tips?

@bobvanderlinden
Copy link
Author

@michaelshobbs I have not tried this using Vagrant, just VirtualBox. To reproduce you could do exactly the same as I did:

  • Create a new virtual machine in VirtualBox.
  • Install Ubuntu Server 14.04.3 LTS with OpenSSH server.
  • Run the following commands to install Docker+Dokku:
$ sudo apt-get update
$ sudo apt-get upgrade
$ wget https://raw.github.com/progrium/dokku/v0.4.0/bootstrap.sh
$ sudo DOKKU_TAG=v0.4.0 bash bootstrap.sh
$ sudo sshcommand acl-add dokku bob
  • Push NodeJS application to dokku@dokku.local:cycle-remote
  • Check sudo docker ps and verify one container is running.
  • sudo reboot
  • Check sudo docker ps again and notice there are 2 containers running.

Also, the necessary fix for Docker is now in 1.9.0-rc1:

  • Add a new unless-stopped restart policy

@michaelshobbs
Copy link
Member

To be clear, my vagrant setup is using VirtualBox underneath. Is the cycle-remote app available publicly? I'd like to compare apples to apples here just in case there's something going on with the app. Also, what are the resource allocations (disk/cpu/memory) for you vbox setup?

@michaelshobbs
Copy link
Member

Ah! I just got this to happen. Ok I see now that if I've done an apps:restart and have a stopped app container, a reboot will in fact start up again. Perhaps in /etc/init/dokku-redeploy.conf we just do a dokku cleanup beforehand. Thoughts?

Near here:
https://github.com/progrium/dokku/blob/ef3480703a81f490f06f30363ea67d7d591d64f6/plugins/00_dokku-standard/install#L22-L23

@michaelshobbs
Copy link
Member

It looks like container 1 started up due to the restart policy and then a new container came up because of dokku-redeploy.conf (i.e. dokku ps:restartall). The difference in my experience here is that container 1 was stopped after the standard DOKKU_WAIT timeout.

@bobvanderlinden given you can recreate this seemingly at will, could you modify /etc/init/dokku-redeploy.confto include the following line before ps:restartall is called?

sudo -i -u dokku /usr/local/bin/dokku cleanup

Let us know if that solves the issue. If not I'd like to know the state of those containers. Can you capture that by adding docker ps -a >> /tmp/dokku_container_log and include that log here?

@bobvanderlinden
Copy link
Author

Oh, also interesting, just found out about docker ps -a. Did the same thing:

$ sudo docker ps -a
CONTAINER ID        IMAGE                       COMMAND                  CREATED              STATUS                          PORTS               NAMES
a0cfea4744ed        dokku/cycle-remote:latest   "/start web"             About a minute ago   Up About a minute                                   serene_thompson
8e1aa9a949f6        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   About a minute ago   Exited (0) About a minute ago                       tender_poitras
06592df830e7        dokku/cycle-remote:latest   "/build"                 2 minutes ago        Exited (0) About a minute ago                       elated_saha
b428c04a7c1d        dokku/cycle-remote:latest   "/bin/bash -c 'cat >>"   2 minutes ago        Exited (0) 2 minutes ago                            sleepy_hodgkin
7a4327efb6d1        dokku/cycle-remote:latest   "/bin/bash -c 'for EN"   2 minutes ago        Exited (0) 2 minutes ago                            modest_tesla
97306fbdbbeb        gliderlabs/herokuish        "/bin/bash -c 'mkdir "   2 minutes ago        Exited (0) 2 minutes ago                            romantic_poitras


$ for i in 1 2 3 4 5; do dokku ps:restart cycle-remote; sleep 60; done; sudo docker ps -a
...
CONTAINER ID        IMAGE                       COMMAND                  CREATED              STATUS                                PORTS               NAMES
ee783a7f057c        dokku/cycle-remote:latest   "/start web"             About a minute ago   Up About a minute                                         thirsty_shockley
038badc1ff4c        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   About a minute ago   Exited (0) About a minute ago                             modest_sinoussi
1172586640a6        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   About a minute ago   Exited (0) About a minute ago                             jovial_sinoussi
e3302a759ba1        dokku/cycle-remote:latest   "/start web"             2 minutes ago        Exited (255) Less than a second ago                       clever_albattani
11e2ea3af881        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   2 minutes ago        Exited (0) 2 minutes ago                                  sleepy_babbage
2407335fbf53        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   2 minutes ago        Exited (0) 2 minutes ago                                  focused_shockley
75c948593e01        dokku/cycle-remote:latest   "/start web"             3 minutes ago        Exited (255) About a minute ago                           prickly_sinoussi
31a425fc71f7        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   3 minutes ago        Exited (0) 3 minutes ago                                  distracted_kowalevski
da6fb0deb17c        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   3 minutes ago        Exited (0) 3 minutes ago                                  focused_bhaskara
daabd61e26db        dokku/cycle-remote:latest   "/start web"             4 minutes ago        Exited (255) 2 minutes ago                                mad_euclid
2fa512de9c0b        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   4 minutes ago        Exited (0) 4 minutes ago                                  serene_brown
8c8b297b01a7        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   4 minutes ago        Exited (0) 4 minutes ago                                  stoic_mcclintock
03bd80d5aeb7        dokku/cycle-remote:latest   "/start web"             6 minutes ago        Exited (255) 3 minutes ago                                elegant_kilby
c91d91f70038        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   6 minutes ago        Exited (0) 6 minutes ago                                  cocky_torvalds
03add1998d41        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   6 minutes ago        Exited (0) 6 minutes ago                                  modest_bhaskara
a0cfea4744ed        dokku/cycle-remote:latest   "/start web"             8 minutes ago        Exited (255) 4 minutes ago                                serene_thompson
8e1aa9a949f6        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   8 minutes ago        Exited (0) 8 minutes ago                                  tender_poitras
06592df830e7        dokku/cycle-remote:latest   "/build"                 10 minutes ago       Exited (0) 8 minutes ago                                  elated_saha
b428c04a7c1d        dokku/cycle-remote:latest   "/bin/bash -c 'cat >>"   10 minutes ago       Exited (0) 10 minutes ago                                 sleepy_hodgkin
7a4327efb6d1        dokku/cycle-remote:latest   "/bin/bash -c 'for EN"   10 minutes ago       Exited (0) 10 minutes ago                                 modest_tesla
97306fbdbbeb        gliderlabs/herokuish        "/bin/bash -c 'mkdir "   10 minutes ago       Exited (0) 10 minutes ago                                 romantic_poitras

$ sudo reboot

$ sudo docker ps -a
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS                      PORTS               NAMES
16de05d09b0b        dokku/cycle-remote:latest   "/start web"             7 seconds ago       Up 6 seconds                                    prickly_rosalind
f645aa06244a        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   8 seconds ago       Exited (0) 7 seconds ago                        stupefied_bardeen
c1b448d52bba        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   9 seconds ago       Exited (0) 8 seconds ago                        determined_elion
ee783a7f057c        dokku/cycle-remote:latest   "/start web"             4 minutes ago       Up 10 seconds                                   thirsty_shockley
038badc1ff4c        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   4 minutes ago       Exited (0) 4 minutes ago                        modest_sinoussi
1172586640a6        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   4 minutes ago       Exited (0) 4 minutes ago                        jovial_sinoussi
e3302a759ba1        dokku/cycle-remote:latest   "/start web"             5 minutes ago       Up 10 seconds                                   clever_albattani
11e2ea3af881        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   5 minutes ago       Exited (0) 5 minutes ago                        sleepy_babbage
2407335fbf53        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   5 minutes ago       Exited (0) 5 minutes ago                        focused_shockley
75c948593e01        dokku/cycle-remote:latest   "/start web"             6 minutes ago       Up 10 seconds                                   prickly_sinoussi
31a425fc71f7        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   6 minutes ago       Exited (0) 6 minutes ago                        distracted_kowalevski
da6fb0deb17c        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   6 minutes ago       Exited (0) 6 minutes ago                        focused_bhaskara
daabd61e26db        dokku/cycle-remote:latest   "/start web"             7 minutes ago       Up 10 seconds                                   mad_euclid
2fa512de9c0b        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   7 minutes ago       Exited (0) 7 minutes ago                        serene_brown
8c8b297b01a7        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   7 minutes ago       Exited (0) 7 minutes ago                        stoic_mcclintock
03bd80d5aeb7        dokku/cycle-remote:latest   "/start web"             8 minutes ago       Up 10 seconds                                   elegant_kilby
c91d91f70038        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   8 minutes ago       Exited (0) 8 minutes ago                        cocky_torvalds
03add1998d41        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   8 minutes ago       Exited (0) 8 minutes ago                        modest_bhaskara
a0cfea4744ed        dokku/cycle-remote:latest   "/start web"             11 minutes ago      Up 10 seconds                                   serene_thompson
8e1aa9a949f6        dokku/cycle-remote:latest   "/bin/bash -c 'mkdir "   11 minutes ago      Exited (0) 11 minutes ago                       tender_poitras
06592df830e7        dokku/cycle-remote:latest   "/build"                 12 minutes ago      Exited (0) 11 minutes ago                       elated_saha
b428c04a7c1d        dokku/cycle-remote:latest   "/bin/bash -c 'cat >>"   12 minutes ago      Exited (0) 12 minutes ago                       sleepy_hodgkin
7a4327efb6d1        dokku/cycle-remote:latest   "/bin/bash -c 'for EN"   12 minutes ago      Exited (0) 12 minutes ago                       modest_tesla
97306fbdbbeb        gliderlabs/herokuish        "/bin/bash -c 'mkdir "   12 minutes ago      Exited (0) 12 minutes ago                       romantic_poitras

@josegonzalez
Copy link
Member

Those containers should be killed after 60 seconds, which is part of our zero-downtime deploys feature. Perhaps we can keep a list of all "killable" containers? We can add/remove containers from this list as they get queued up for deletion and then kill all "killable" containers after a reboot...

@bobvanderlinden
Copy link
Author

@josegonzalez From what I could tell here, the containers are only stopped. Only if the stopping is unsuccessful they are killed. However, those containers are never actually removed. Docker will still start these stopped containers upon reboot because of the restart policy.
Should a docker rm be added to https://github.com/progrium/dokku/blob/1e543a/dokku#L199? Should the restart policy be rolled back? Should we wait for dockers unless-stopped restart policy? Or are there other solutions?

@josegonzalez
Copy link
Member

Odd, I thought it had a docker rm in there as well. I'm pretty sure that's a bug, though @michaelshobbs might be more familiar with that bit of code.

@xadh00m
Copy link
Contributor

xadh00m commented Oct 16, 2015

I´d like to add that we just ran into the same issue. We provision a VM with a couple of services via dokku (with VHOST set) and finally stop the VM to export it for distribution to our customers. When the VM is imported and started with VirtualBox "some" of the service containers are started more then one time and the IPs set in dokku/serviceId/IP.web.1 are not valid anymore. Therefore the services cannot be reached anymore.
We could also reproduce this issue with the dokku vagrant box and one of our services.

@josegonzalez
Copy link
Member

Yeah so we at least should have a docker rm call in there I think. Looks like it was never there in the first place, though I can't think of any reason we can't have it.

As far as the reboot is concerned, perhaps we should stop/kill all app containers first - ps:stop-right-meow could query for any running instances matching the name of your app container - and then call the rebuild command. That should work in theory, right?

We can also listen to the shutdown or reboot runlevel and stop all containers that should have been killed immediately. Not sure how that might be implemented, but it's definitely an idea.

@bobvanderlinden
Copy link
Author

Adding docker rm and removing the ps:restartall on boot would be enough I think. Docker handles restarting any containers, so dokku doesn't need to intervene with this. docker rm would make sure Docker doesn't start any deprecated containers.

The only downside to using docker rm is that containers that were previously running cannot be turned back on. This can be handy if you notice that the current container contains errors, so you can revert back to a previous container more easily/efficiently. But at the moment that isn't supported (I think) by Dokku, so it isn't a very strong downside.

bobvanderlinden added a commit to bobvanderlinden/dokku that referenced this issue Oct 16, 2015
This resolves issues where docker would start old containers upon
reboot. Related to issue dokku#1505.
@bobvanderlinden
Copy link
Author

PR #1569 should solve the problem. It did for me.

@michaelshobbs
Copy link
Member

Few thoughts here

  1. removing the app container(s) consequently removes the ability to inspect the full previous deployment. i find this useful in troubleshooting
  2. we're "optimizing" for a bug in docker due to our hastiness in implementing a feature that doesn't yet jive with our use case (i.e. restart policies)

i'd prefer we remove restart policies until they are better fleshed out in docker 1.9.

@bobvanderlinden
Copy link
Author

@michaelshobbs

  1. Indeed. That would be useful.
  2. The existing restart policies are valuable as well. For the moment we also don't know how Docker 1.9 will allow "on-failure=" combined with "unless-stopped" (only "always" + "unless-stopped"), so we probably won't get the same functionality once 1.9 is released.

That said, whatever fixes the problem for now is fine for me.

@michaelshobbs
Copy link
Member

The usefulness of auto restarting an app makes sense to me. A standard example is using a process manager like supervisor to restart a node app when it hits an uncaught exception.

The desire to push this responsibility to the container daemon as one method of doing this is also is clear to me. It simplifies the deployment as a whole since you don't need to run a process manager anymore. However, this feature is new to docker, they are still figuring it out and I'm sure they will soon. Side bar: @josegonzalez or @bobvanderlinden have either of you chimed in over there about our use case?

My strong opinion is that we don't add complexity to dokku, potentially removing the ability to troubleshoot the entire deployment process, and burn cycles to implement a docker feature that is clearly in flux.

@josegonzalez can we remove the auto restart policy on the app containers and recommend a process manager for now, if desired?

@josegonzalez
Copy link
Member

I've been fine with removing auto-restart from the get-go and revisiting the on-failure stuff later. Annoying that implementing that feature ended up breaking other stuff :(

I don't think this needs a major release, can be a patch, and we'll just add docs about how to resurrect the feature and why we don't (yet) include it by default.

@bobvanderlinden
Copy link
Author

@michaelshobbs Sorry for the late reply. I only asked here: moby/moby#15348 (comment) about on-failure in combination with unless-stopped, but got no response yet. I'll create an issue about using the combination.

I agree that any extra complexity shouldn't be needed in Dokku. That said, auto-restart upon failures is a very nice feature and it would be a shame if it were to be removed. I also did not think the 'old' containers would stay indefinitely when they are not used anymore. It can cause disk problems. That is why I still like the docker stop+rm idea. Maybe it should be an option, which solves the reboot problems for those who have problems with that right now. Same goes for the restart policy: a global option to turn it on/off could be considered.

@michaelshobbs
Copy link
Member

If we remove the broken restart policy then the disk space thing is a non-issue.

For now, the prescribed method of auto restarting an app will have to be running a process manager inside the container. Fortunately you can do this easily either with a dokku plugin like dokku-logging-supervisord or using something like supervisor if you're deploying a node app.

@bobvanderlinden
Copy link
Author

@michaelshobbs Alright. Yes, dokku-logging-supervisord does seem like a good alternative.

@josegonzalez
Copy link
Member

You could also implement this feature as a docker-options option.

@michaelshobbs
Copy link
Member

@josegonzalez: 👍

@bobvanderlinden
Copy link
Author

@josegonzalez Aah, that's essentially the same as the previous default. Very good to know! Thanks for all the suggestions, I'm closing this.

@wffurr
Copy link

wffurr commented Mar 4, 2017

This is happening again after #2290. Adding restart policy on-failure:10 to docker containers by default causes them to restart on boot. When a container is retired, aka stopped after deploying a new version or a ps:restart, it should have its restart policy set to no, possibly in the retire containers loop in dokku_deploy_cmd in

for oldid in $oldids; do

@JackCuthbert
Copy link

@bobvanderlinden @wffurr This is happening for me as well. Multiple old containers running the same things after reboot or restart.

@josegonzalez
Copy link
Member

This is a result of docker losing the preferred state of the application after a reboot, as well as not respecting the associated restart policy. This will be partially fixed by #2403, as we can then rebuild the networking configuration properly on reboot and then restart applications as desired.

If you'd like to see movement on fixing the issue, please either follow along with that issue or help contribute to fixing it. Thanks.

@dokku dokku locked and limited conversation to collaborators Mar 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants