From 41b3c71d022b1111ff12a0484e20a7e2b8670c3d Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Fri, 26 Dec 2025 11:49:02 +0100 Subject: [PATCH] fix(terminal): add sudo for non-root users to access Docker socket in terminal command --- app/Livewire/Project/Shared/Terminal.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Livewire/Project/Shared/Terminal.php b/app/Livewire/Project/Shared/Terminal.php index 3c2abc84c..ae68b2354 100644 --- a/app/Livewire/Project/Shared/Terminal.php +++ b/app/Livewire/Project/Shared/Terminal.php @@ -57,7 +57,14 @@ public function sendTerminalCommand($isContainer, $identifier, $serverUuid) $shellCommand = 'PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin && '. 'if [ -f ~/.profile ]; then . ~/.profile; fi && '. 'if [ -n "$SHELL" ] && [ -x "$SHELL" ]; then exec $SHELL; else sh; fi'; - $command = SshMultiplexingHelper::generateSshCommand($server, "docker exec -it {$escapedIdentifier} sh -c '{$shellCommand}'"); + + // Add sudo for non-root users to access Docker socket + $dockerCommand = "docker exec -it {$escapedIdentifier} sh -c '{$shellCommand}'"; + if ($server->isNonRoot()) { + $dockerCommand = "sudo {$dockerCommand}"; + } + + $command = SshMultiplexingHelper::generateSshCommand($server, $dockerCommand); } else { $shellCommand = 'PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin && '. 'if [ -f ~/.profile ]; then . ~/.profile; fi && '.