How can I prevent Nextcloud containers from starting on boot with docker

My server is set up in a way where I need to issue some commands before the mount point that Nextcloud is running on becomes available. For this reason, I always manually start all docker containers after I have set up the mount point instead of setting them to a restart policy like “always” or “unless-stopped”.

I have setup the AIO master container with docker compose and it’s working great. The only problem is, that the master container creates all the other containers with a restart policy of “unless-stopped”. This leads to the result, that on boot of my server, Nextcloud is not reachable because the master container is not running and the mount is not available, but all the other containers spin up in a broken way automatically.

Is there a way to configure the master container to spin up the other containers with a different restart policy so that I can start all of them by bringing up the master container manually and the don’t start automatically?

I guess the help system is also forcing me to add all of this unrelated information:

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    33.0.0

  • Operating system and version (e.g., Ubuntu 24.04):
    Ubuntu 24.04.4

  • Web server and version (e.g, Apache 2.4.25):
    no idea, doesn’t matter

  • Reverse proxy and version _(e.g. nginx 1.27.2):
    nginx/1.24.0

  • PHP version (e.g, 8.3):
    8.3.30

  • Is this the first time you’ve seen this error? (Yes / No)
    n/a

  • When did this problem seem to first start?
    n/a

  • Installation method (e.g. AIO, NCP, Bare Metal/Archive, etc.)
    AIO with docker compose

  • Are you using Cloudflare, mod_security, or similar? (Yes / No)
    No

Summary of the issue you are facing:

blep

Steps to replicate it (hint: details matter!):

  1. n/a

  2. n/a

  3. n/a

Log entries

Nextcloud

Please provide the log entries from your Nextcloud log that are generated during the time of problem (via the Copy raw option from Administration settings->Logging screen or from your nextcloud.log located in your data directory). Feel free to use a pastebin/gist service if necessary.

PASTE HERE

Web Browser

If the problem is related to the Web interface, open your browser inspector Console and Network tabs while refreshing (reloading) and reproducing the problem. Provide any relevant output/errors here that appear.

PASTE

Web server / Reverse Proxy

The output of your Apache/nginx/system log in /var/log/____:

PASTE HERE

Configuration

Nextcloud

The output of occ config:list system or similar is best, but, if not possible, the contents of your config.php file from /path/to/nextcloud is fine (make sure to remove any identifiable information!):

PASTE HERE

Apps

The output of occ app:list (if possible).

You could mount them at boot with /etc/fstab

Sure. You could either delay the start of docker itself (which probably uses systemctl) or you could use delay and healthcheck inside of docker.

I personally would just mount at boot. Sounds like less trouble to me.

2 Likes

I can’t mount it on boot because I have to decrypt the drive with LUKS first, so this is not an option. And I have other docker containers which I do want to start on boot so delaying all of docker is also not an option.

you don’t have to delay all containers.
Create a “waiting container” and make Nextcloud dependent on that.

That way you should be able to only delay Nextcloud.

Is there a way to instruct the AIO master container to set a dependency for all the containers it spins up? If that’s possible it would also work but at that point I could just use the same mechanism to change the restart policy instead, no? Either way, if you know how to do this, please let me now.

What you could do is to stop the containers before restarting the server. Then they will not automatically start on server boot.