diff --git a/src/platform.js b/src/platform.js index 84876e5e1..fc8a30dee 100644 --- a/src/platform.js +++ b/src/platform.js @@ -133,11 +133,10 @@ function pruneInfraImages(callback) { function stopContainers(existingInfra, callback) { // always stop addons to restart them on any infra change, regardless of minor or major update if (existingInfra.version !== infra.version) { - // TODO: only nuke containers with isCloudronManaged=true debug('stopping all containers for infra upgrade'); async.series([ - shell.exec.bind(null, 'stopContainers', 'docker ps -qa --filter \'network=cloudron\' | xargs --no-run-if-empty docker stop'), - shell.exec.bind(null, 'stopContainers', 'docker ps -qa --filter \'network=cloudron\' | xargs --no-run-if-empty docker rm -f') + shell.exec.bind(null, 'stopContainers', 'docker ps -qa --filter \'label=isCloudronManaged\' | xargs --no-run-if-empty docker stop'), + shell.exec.bind(null, 'stopContainers', 'docker ps -qa --filter \'label=isCloudronManaged\' | xargs --no-run-if-empty docker rm -f') ], callback); } else { assert(typeof infra.images, 'object'); @@ -150,8 +149,8 @@ function stopContainers(existingInfra, callback) { let filterArg = changedAddons.map(function (c) { return `--filter 'name=${c}'`; }).join(' '); // name=c matches *c*. required for redis-{appid} // ignore error if container not found (and fail later) so that this code works across restarts async.series([ - shell.exec.bind(null, 'stopContainers', `docker ps -qa ${filterArg} --filter 'network=cloudron' | xargs --no-run-if-empty docker stop || true`), - shell.exec.bind(null, 'stopContainers', `docker ps -qa ${filterArg} --filter 'network=cloudron' | xargs --no-run-if-empty docker rm -f || true`) + shell.exec.bind(null, 'stopContainers', `docker ps -qa ${filterArg} --filter 'label=isCloudronManaged' | xargs --no-run-if-empty docker stop || true`), + shell.exec.bind(null, 'stopContainers', `docker ps -qa ${filterArg} --filter 'label=isCloudronManaged' | xargs --no-run-if-empty docker rm -f || true`) ], callback); } }