statically allocate app container IPs
We removed httpPort with the assumption that docker allocated IPs and kept them as long as the container is around. This turned out to be not true because the IP changes on even container restart. So we now allocate IPs statically. The iprange makes sure we don't overlap with addons and other CI app or JupyterHub apps. https://github.com/moby/moby/issues/6743 https://github.com/moby/moby/pull/19001
This commit is contained in:
@@ -54,7 +54,8 @@ function start(callback) {
|
||||
if (error) return callback(error);
|
||||
|
||||
async.series([
|
||||
(next) => { if (existingInfra.version !== infra.version) removeAllContainers(existingInfra, next); else next(); },
|
||||
(next) => { if (existingInfra.version !== infra.version) removeAllContainers(next); else next(); },
|
||||
createDockerNetwork,
|
||||
markApps.bind(null, existingInfra), // mark app state before we start addons. this gives the db import logic a chance to mark an app as errored
|
||||
graphs.startGraphite.bind(null, existingInfra),
|
||||
sftp.startSftp.bind(null, existingInfra),
|
||||
@@ -122,7 +123,7 @@ function pruneInfraImages(callback) {
|
||||
}, callback);
|
||||
}
|
||||
|
||||
function removeAllContainers(existingInfra, callback) {
|
||||
function removeAllContainers(callback) {
|
||||
debug('removeAllContainers: removing all containers for infra upgrade');
|
||||
|
||||
async.series([
|
||||
@@ -131,6 +132,16 @@ function removeAllContainers(existingInfra, callback) {
|
||||
], callback);
|
||||
}
|
||||
|
||||
function createDockerNetwork(callback) {
|
||||
debug('createDockerNetwork: creating cloudron network');
|
||||
|
||||
// this gives docker the network range 172.18.0.0-172.18.15.255
|
||||
async.series([
|
||||
shell.exec.bind(null, 'createDockerNetwork', 'docker network rm cloudron || true'), // may not exist on first run
|
||||
shell.exec.bind(null, 'createDockerNetwork', 'docker network create --subnet=172.18.0.0/16 --ip-range=172.18.0.0/20 cloudron || true') // can fail if (user) containers are still attached
|
||||
], callback);
|
||||
}
|
||||
|
||||
function markApps(existingInfra, callback) {
|
||||
if (existingInfra.version === 'none') { // cloudron is being restored from backup
|
||||
debug('markApps: restoring installed apps');
|
||||
|
||||
Reference in New Issue
Block a user