Skip to content

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.

fix(docker): enhance hostname and GPU option validation in Docker run to compose conversion

Andras Bacsai08d2ad83ee8c
diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php
index f2554f715c..bade67eb87 100644
--- a/bootstrap/helpers/docker.php
+++ b/bootstrap/helpers/docker.php
@@ -787,7 +787,7 @@ function convertDockerRunToCompose(?string $custom_docker_run_options = null)
$regexForParsingHostname = '/--hostname(?:=|\s+)([^\s]+)/';
preg_match($regexForParsingHostname, $custom_docker_run_options, $hostname_matches);
$value = $hostname_matches[1] ?? null;
- if ($value) {
+ if ($value && ! empty(trim($value))) {
$options[$option][] = $value;
$options[$option] = array_unique($options[$option]);
}
@@ -829,7 +829,7 @@ function convertDockerRunToCompose(?string $custom_docker_run_options = null)
});
$compose_options->put($mapping[$option], $ulimits);
} elseif ($option === '--shm-size' || $option === '--hostname') {
- if (! is_null($value) && is_array($value) && count($value) > 0) {
+ if (! is_null($value) && is_array($value) && count($value) > 0 && ! empty(trim($value[0]))) {
$compose_options->put($mapping[$option], $value[0]);
}
} elseif ($option === '--gpus') {
@@ -837,7 +837,7 @@ function convertDockerRunToCompose(?string $custom_docker_run_options = null)
'driver' => 'nvidia',
'capabilities' => ['gpu'],
];
- if (! is_null($value) && is_array($value) && count($value) > 0) {
+ if (! is_null($value) && is_array($value) && count($value) > 0 && ! empty(trim($value[0]))) {
if (str($value[0]) != 'all') {
if (str($value[0])->contains(',')) {
$payload['device_ids'] = str($value[0])->explode(',')->toArray();