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 && '.