dokku / dokku-mongo

a mongo plugin for dokku
MIT License
177 stars 32 forks source link

how to stop from automatically starting? #150

Closed bradwbradw closed 1 year ago

bradwbradw commented 2 years ago

If you're using Dokku - especially for commercial purposes - consider donating to project development via OpenCollective or Patreon. Funds go to general development, support, and infrastructure costs.

If you'd like to sponsor specific functionality, see the project's Sponsoring document.

If you need support for a version of Dokku that is more than a year old, your issue may be closed without an answer. Please upgrade to a recent version before filing an issue.

Description of problem

My mongo service abc is connected to an app xyz that is "exited". it was stopped manually and dokku does not start it up (correct behaviour).

I wouldn't expect the connected mongo to start up if the host app isn't running, but it does start. I see status: running when using dokku mongo:info abc.

Even if i run dokku mongo:stop abc that will stop the mongo instance, but it starts up automatically on server reboot, even though I stopped it manually (contrary to the behaviour of apps)

How reproducible

reproducible

Steps to Reproduce

  1. set up app xyz, mongo service abc, connect them.
  2. deploy and start xyz
  3. run dokku ps:stop xyz
  4. run dokku mongo:stop abc
  5. reboot the environment

Actual Results

dokku mongo:info abc shows Status=running`

Expected Results

dokku mongo:info abc shows Status=exited`

Environment Information

dokku report APP_NAME output

-----> uname: Linux ae.seapunk.net 4.15.0-180-generic #189-Ubuntu SMP Wed May 18 14:13:57 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
-----> memory:
                     total        used        free      shared  buff/cache   available
       Mem:           1993         331         642           0        1019        1477
       Swap:             0           0           0
-----> docker version:
       Client: Docker Engine - Community
        Version:           20.10.16
        API version:       1.41
        Go version:        go1.17.10
        Git commit:        aa7e414
        Built:             Thu May 12 09:17:28 2022
        OS/Arch:           linux/amd64
        Context:           default
        Experimental:      true

       Server: Docker Engine - Community
        Engine:
         Version:          20.10.16
         API version:      1.41 (minimum version 1.12)
         Go version:       go1.17.10
         Git commit:       f756502
         Built:            Thu May 12 09:15:33 2022
         OS/Arch:          linux/amd64
         Experimental:     false
        containerd:
         Version:          1.6.4
         GitCommit:        212e8b6fa2f44b9c21b2798135fc6fb7c53efc16
        runc:
         Version:          1.1.1
         GitCommit:        v1.1.1-0-g52de29d
        docker-init:
         Version:          0.19.0
         GitCommit:        de40ad0
-----> docker daemon info:
WARNING: No swap limit support
       Client:
        Context:    default
        Debug Mode: true
        Plugins:
         app: Docker App (Docker Inc., v0.9.1-beta3)
         buildx: Docker Buildx (Docker Inc., v0.8.2-docker)
         scan: Docker Scan (Docker Inc., v0.17.0)

       Server:
        Containers: 7
         Running: 3
         Paused: 0
         Stopped: 4
        Images: 123
        Server Version: 20.10.16
        Storage Driver: overlay2
         Backing Filesystem: extfs
         Supports d_type: true
         Native Overlay Diff: true
         userxattr: false
        Logging Driver: json-file
        Cgroup Driver: cgroupfs
        Cgroup Version: 1
        Plugins:
         Volume: local
         Network: bridge host ipvlan macvlan null overlay
         Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
        Swarm: inactive
        Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
        Default Runtime: runc
        Init Binary: docker-init
        containerd version: 212e8b6fa2f44b9c21b2798135fc6fb7c53efc16
        runc version: v1.1.1-0-g52de29d
        init version: de40ad0
        Security Options:
         apparmor
         seccomp
          Profile: default
        Kernel Version: 4.15.0-180-generic
        Operating System: Ubuntu 18.04.6 LTS
        OSType: linux
        Architecture: x86_64
        CPUs: 1
        Total Memory: 1.946GiB
        Name: ae.seapunk.net
        ID: DNV4:CTUQ:72J5:2COZ:I6ZZ:5AW3:E3HA:GBIK:TGKW:3RTH:FCC6:IM72
        Docker Root Dir: /var/lib/docker
        Debug Mode: false
        Registry: https://index.docker.io/v1/
        Labels:
        Experimental: false
        Insecure Registries:
         127.0.0.0/8
        Live Restore Enabled: false

-----> git version: git version 2.17.1
-----> sigil version: 0.9.0build+bc921b7
-----> herokuish version:
       herokuish: 0.5.35
       buildpacks:
         heroku-buildpack-multi     v1.0.0
         heroku-buildpack-ruby      v240
         heroku-buildpack-nodejs    v195
         heroku-buildpack-clojure   v87
         heroku-buildpack-python    v210
         heroku-buildpack-java      v69
         heroku-buildpack-gradle    v36
         heroku-buildpack-scala     v92
         heroku-buildpack-play      v26
         heroku-buildpack-php       v216
         heroku-buildpack-go        v161
         heroku-buildpack-nginx     v16
         buildpack-null             v3
-----> dokku version: dokku version 0.27.4
-----> plugn version: plugn: 0.12.0build+3a27594
-----> dokku plugins:
         00_dokku-standard    0.27.4 enabled    dokku core standard plugin
         20_events            0.27.4 enabled    dokku core events logging plugin
         app-json             0.27.4 enabled    dokku core app-json plugin
         apps                 0.27.4 enabled    dokku core apps plugin
         builder              0.27.4 enabled    dokku core builder plugin
         builder-dockerfile   0.27.4 enabled    dokku core builder-dockerfile plugin
         builder-herokuish    0.27.4 enabled    dokku core builder-herokuish plugin
         builder-null         0.27.4 enabled    dokku core builder-null plugin
         builder-pack         0.27.4 enabled    dokku core builder-pack plugin
         buildpacks           0.27.4 enabled    dokku core buildpacks plugin
         certs                0.27.4 enabled    dokku core certificate management plugin
         checks               0.27.4 enabled    dokku core checks plugin
         common               0.27.4 enabled    dokku core common plugin
         config               0.27.4 enabled    dokku core config plugin
         cron                 0.27.4 enabled    dokku core cron plugin
         docker-options       0.27.4 enabled    dokku core docker-options plugin
         domains              0.27.4 enabled    dokku core domains plugin
         enter                0.27.4 enabled    dokku core enter plugin
         git                  0.27.4 enabled    dokku core git plugin
         letsencrypt          0.9.4 enabled    Automated installation of let's encrypt TLS certificates
         logs                 0.27.4 enabled    dokku core logs plugin
         mongo                1.17.4 enabled    dokku mongo service plugin
         network              0.27.4 enabled    dokku core network plugin
         nginx-vhosts         0.27.4 enabled    dokku core nginx-vhosts plugin
         plugin               0.27.4 enabled    dokku core plugin plugin
         proxy                0.27.4 enabled    dokku core proxy plugin
         ps                   0.27.4 enabled    dokku core ps plugin
         registry             0.27.4 enabled    dokku core registry plugin
         repo                 0.27.4 enabled    dokku core repo plugin
         resource             0.27.4 enabled    dokku core resource plugin
         run                  0.27.4 enabled    dokku core run plugin
         scheduler            0.27.4 enabled    dokku core scheduler plugin
         scheduler-docker-local 0.27.4 enabled    dokku core scheduler-docker-local plugin
         scheduler-null       0.27.4 enabled    dokku core scheduler-null plugin
         shell                0.27.4 enabled    dokku core shell plugin
         ssh-keys             0.27.4 enabled    dokku core ssh-keys plugin
         storage              0.27.4 enabled    dokku core storage plugin
         trace                0.27.4 enabled    dokku core trace plugin
=====> xyz-staging app-json information
       App json computed selected:    app.json
       App json global selected:      app.json
       App json selected:
=====> xyz-staging app information
       App created at:                1653606775
       App deploy source:             xyz-staging
       App deploy source metadata:    xyz-staging
       App dir:                       /home/dokku/xyz-staging
       App locked:                    false
=====> xyz-staging builder information
       Builder build dir:
       Builder computed build dir:
       Builder computed selected:
       Builder global build dir:
       Builder global selected:
       Builder selected:
=====> xyz-staging builder-dockerfile information
       Builder dockerfile computed dockerfile path: Dockerfile
       Builder dockerfile global dockerfile path: Dockerfile
       Builder dockerfile dockerfile path:
=====> xyz-staging builder-pack information
       Builder pack computed projecttoml path: project.toml
       Builder pack global projecttoml path: project.toml
       Builder pack projecttoml path:
=====> xyz-staging buildpacks information
       Buildpacks computed stack:     gliderlabs/herokuish:latest-20
       Buildpacks global stack:
       Buildpacks list:
       Buildpacks stack:
=====> xyz-staging ssl information
       Ssl dir:                       /home/dokku/xyz-staging/tls
       Ssl enabled:                   true
       Ssl hostnames:                 2022staging.xyz.gs
       Ssl expires at:                Aug  8 23:06:10 2022 GMT
       Ssl issuer:                    C = US, O = Let's Encrypt, CN = R3
       Ssl starts at:                 May 10 23:06:11 2022 GMT
       Ssl subject:                   subject=CN = 2022staging.xyz.gs
       Ssl verified:                  self signed
=====> xyz-staging checks information
       Checks disabled list:          none
       Checks skipped list:           none
=====> xyz-staging cron information
       Cron task count:               0
=====> xyz-staging docker options information
       Docker options build:          --link dokku.mongo.xyz-staging:dokku-mongo-xyz-staging
       Docker options deploy:         --link dokku.mongo.xyz-staging:dokku-mongo-xyz-staging --restart=on-failure:10
       Docker options run:            --link dokku.mongo.xyz-staging:dokku-mongo-xyz-staging
=====> xyz-staging domains information
       Domains app enabled:           true
       Domains app vhosts:            2022staging.xyz.gs
       Domains global enabled:        true
       Domains global vhosts:         ae.seapunk.net
=====> xyz-staging git information
       Git deploy branch:             master
       Git global deploy branch:      master
       Git keep git dir:              false
       Git rev env var:               GIT_REV
       Git sha:                       4d2ef51
       Git last updated at:           1652227156
=====> xyz-staging logs information
       Logs computed max size:        10m
       Logs global max size:          10m
       Logs global vector sink:
       Logs max size:
       Logs vector sink:
=====> xyz-staging network information
       Network attach post create:
       Network attach post deploy:
       Network bind all interfaces:          false
       Network computed attach post create:
       Network computed attach post deploy:
       Network computed bind all interfaces: false
       Network computed initial network:
       Network computed tld:
       Network global attach post create:
       Network global attach post deploy:
       Network global bind all interfaces:   false
       Network global initial network:
       Network global tld:
       Network initial network:
       Network static web listener:
       Network tld:
       Network web listeners:                172.17.0.7:5000
=====> xyz-staging nginx information
       Nginx access log format:
       Nginx access log path:         /var/log/nginx/xyz-staging-access.log
       Nginx bind address ipv4:
       Nginx bind address ipv6:       ::
       Nginx client max body size:
       Nginx disable custom config:   false
       Nginx error log path:          /var/log/nginx/xyz-staging-error.log
       Nginx global hsts:             true
       Nginx computed hsts:           true
       Nginx hsts:
       Nginx hsts include subdomains: true
       Nginx hsts max age:            15724800
       Nginx hsts preload:            false
       Nginx proxy buffer size:       4096
       Nginx proxy buffering:         on
       Nginx proxy buffers:           8 4096
       Nginx proxy busy buffers size: 8192
       Nginx proxy read timeout:      60s
       Nginx last visited at:         1653604185
       Nginx x forwarded for value:   $remote_addr
       Nginx x forwarded port value:  $server_port
       Nginx x forwarded proto value: $scheme
       Nginx x forwarded ssl:
=====> xyz-staging proxy information
       Proxy enabled:                 true
       Proxy port map:                http:80:5000 https:443:5000
       Proxy type:                    nginx
=====> xyz-staging ps information
       Deployed:                      true
       Processes:                     1
       Ps can scale:                  true
       Ps computed procfile path:     Procfile
       Ps global procfile path:       Procfile
       Ps procfile path:
       Ps restart policy:             on-failure:10
       Restore:                       false
       Running:                       false
       Status web 1:                  exited (CID: e0f0f5afd09)
=====> xyz-staging registry information
       Registry computed image repo:      dokku/xyz-staging
       Registry computed push on release: false
       Registry computed server:
       Registry global push on release:
       Registry global server:
       Registry image repo:
       Registry push on release:
       Registry server:
       Registry tag version:
=====> xyz-staging resource information
=====> xyz-staging scheduler information
       Scheduler computed selected:   docker-local
       Scheduler global selected:     docker-local
       Scheduler selected:
=====> xyz-staging scheduler-docker-local information
       Scheduler docker local disable chown:
       Scheduler docker local parallel schedule count:
=====> xyz-staging storage information
       Storage build mounts:
       Storage deploy mounts:
       Storage run mounts:

Thanks for any help, or workaround suggestions

How (deb/make/rpm) and where (AWS, VirtualBox, physical, etc.) was Dokku installed?:

Digital Ocean, debian installation.

Additional information

n/a

josegonzalez commented 1 year ago

Sorry for the late reply.

This is due to us not properly handling the start/stop status of a container in the pre-restore trigger. That trigger is called on server reboot, via dokku ps:restore.

The unfortunate thing is that unless a container is destroyed, docker will restart it on server boot (not sure why, thats just been my annoying experience) even if you manually stop it. As such, I think if you don't want a service running on reboot, the best way is to run the :stop subcommand so the container won't exist (that pauses and removes the container).

josegonzalez commented 1 year ago

Ah a small update: The :stop command is what you want now. There is a new :pause that simply stops the container, while :stop also removes it.