An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix: prevent container name conflict when updating database port mappings
Andras Bacsai8d280b4aac3f
diff --git a/app/Actions/Database/StartClickhouse.php b/app/Actions/Database/StartClickhouse.phpindex f218fcabb0..38f6d7bc83 100644--- a/app/Actions/Database/StartClickhouse.php+++ b/app/Actions/Database/StartClickhouse.php@@ -105,6 +105,8 @@ class StartClickhouse$this->commands[] = "echo '{$readme}' > $this->configuration_dir/README.md";$this->commands[] = "echo 'Pulling {$database->image} image.'";$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml pull";+ $this->commands[] = "docker stop --timeout=10 $container_name 2>/dev/null || true";+ $this->commands[] = "docker rm -f $container_name 2>/dev/null || true";$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";$this->commands[] = "echo 'Database started.'";diff --git a/app/Actions/Database/StartDragonfly.php b/app/Actions/Database/StartDragonfly.phpindex 0db73ba07b..300221d249 100644--- a/app/Actions/Database/StartDragonfly.php+++ b/app/Actions/Database/StartDragonfly.php@@ -192,6 +192,8 @@ class StartDragonflyif ($this->database->enable_ssl) {$this->commands[] = "chown -R 999:999 $this->configuration_dir/ssl/server.key $this->configuration_dir/ssl/server.crt";}+ $this->commands[] = "docker stop --timeout=10 $container_name 2>/dev/null || true";+ $this->commands[] = "docker rm -f $container_name 2>/dev/null || true";$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";$this->commands[] = "echo 'Database started.'";diff --git a/app/Actions/Database/StartKeydb.php b/app/Actions/Database/StartKeydb.phpindex 2908eb9c11..3a2ceebb36 100644--- a/app/Actions/Database/StartKeydb.php+++ b/app/Actions/Database/StartKeydb.php@@ -208,6 +208,8 @@ class StartKeydbif ($this->database->enable_ssl) {$this->commands[] = "chown -R 999:999 $this->configuration_dir/ssl/server.key $this->configuration_dir/ssl/server.crt";}+ $this->commands[] = "docker stop --timeout=10 $container_name 2>/dev/null || true";+ $this->commands[] = "docker rm -f $container_name 2>/dev/null || true";$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";$this->commands[] = "echo 'Database started.'";diff --git a/app/Actions/Database/StartMariadb.php b/app/Actions/Database/StartMariadb.phpindex 11b424ff8f..8a936c8aef 100644--- a/app/Actions/Database/StartMariadb.php+++ b/app/Actions/Database/StartMariadb.php@@ -209,6 +209,8 @@ class StartMariadb$this->commands[] = "echo '{$readme}' > $this->configuration_dir/README.md";$this->commands[] = "echo 'Pulling {$database->image} image.'";$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml pull";+ $this->commands[] = "docker stop --timeout=10 $container_name 2>/dev/null || true";+ $this->commands[] = "docker rm -f $container_name 2>/dev/null || true";$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";$this->commands[] = "echo 'Database started.'";if ($this->database->enable_ssl) {diff --git a/app/Actions/Database/StartMongodb.php b/app/Actions/Database/StartMongodb.phpindex 0bf6ab253f..19699d6849 100644--- a/app/Actions/Database/StartMongodb.php+++ b/app/Actions/Database/StartMongodb.php@@ -260,6 +260,8 @@ class StartMongodb$this->commands[] = "echo '{$readme}' > $this->configuration_dir/README.md";$this->commands[] = "echo 'Pulling {$database->image} image.'";$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml pull";+ $this->commands[] = "docker stop --timeout=10 $container_name 2>/dev/null || true";+ $this->commands[] = "docker rm -f $container_name 2>/dev/null || true";$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";if ($this->database->enable_ssl) {$this->commands[] = executeInDocker($this->database->uuid, 'chown mongodb:mongodb /etc/mongo/certs/server.pem');diff --git a/app/Actions/Database/StartMysql.php b/app/Actions/Database/StartMysql.phpindex bf81d01abe..25546fa9d3 100644--- a/app/Actions/Database/StartMysql.php+++ b/app/Actions/Database/StartMysql.php@@ -210,6 +210,8 @@ class StartMysql$this->commands[] = "echo '{$readme}' > $this->configuration_dir/README.md";$this->commands[] = "echo 'Pulling {$database->image} image.'";$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml pull";+ $this->commands[] = "docker stop --timeout=10 $container_name 2>/dev/null || true";+ $this->commands[] = "docker rm -f $container_name 2>/dev/null || true";$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";if ($this->database->enable_ssl) {diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.phpindex 6cdf32e270..ac011acbe2 100644--- a/app/Actions/Database/StartPostgresql.php+++ b/app/Actions/Database/StartPostgresql.php@@ -223,6 +223,8 @@ class StartPostgresql$this->commands[] = "echo '{$readme}' > $this->configuration_dir/README.md";$this->commands[] = "echo 'Pulling {$database->image} image.'";$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml pull";+ $this->commands[] = "docker stop --timeout=10 $container_name 2>/dev/null || true";+ $this->commands[] = "docker rm -f $container_name 2>/dev/null || true";$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";if ($this->database->enable_ssl) {$this->commands[] = executeInDocker($this->database->uuid, "chown {$this->database->postgres_user}:{$this->database->postgres_user} /var/lib/postgresql/certs/server.key /var/lib/postgresql/certs/server.crt");diff --git a/app/Actions/Database/StartRedis.php b/app/Actions/Database/StartRedis.phpindex c040ec3913..8a7ae42a43 100644--- a/app/Actions/Database/StartRedis.php+++ b/app/Actions/Database/StartRedis.php@@ -205,6 +205,8 @@ class StartRedisif ($this->database->enable_ssl) {$this->commands[] = "chown -R 999:999 $this->configuration_dir/ssl/server.key $this->configuration_dir/ssl/server.crt";}+ $this->commands[] = "docker stop --timeout=10 $container_name 2>/dev/null || true";+ $this->commands[] = "docker rm -f $container_name 2>/dev/null || true";$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";$this->commands[] = "echo 'Database started.'";diff --git a/app/Actions/Database/StopDatabase.php b/app/Actions/Database/StopDatabase.phpindex 5c881e7433..63f5b19790 100644--- a/app/Actions/Database/StopDatabase.php+++ b/app/Actions/Database/StopDatabase.php@@ -49,7 +49,7 @@ class StopDatabase{$server = $database->destination->server;instant_remote_process(command: [- "docker stop --time=$timeout $containerName",+ "docker stop --timeout=$timeout $containerName","docker rm -f $containerName",], server: $server, throwError: false);}