diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php index 5905ed3c1..e97bc3732 100644 --- a/bootstrap/helpers/docker.php +++ b/bootstrap/helpers/docker.php @@ -1000,6 +1000,7 @@ function convertDockerRunToCompose(?string $custom_docker_run_options = null) '--ulimit', '--device', '--shm-size', + '--dns', ]); $mapping = collect([ '--cap-add' => 'cap_add', @@ -1013,6 +1014,7 @@ function convertDockerRunToCompose(?string $custom_docker_run_options = null) '--ip' => 'ip', '--ip6' => 'ip6', '--shm-size' => 'shm_size', + '--dns' => 'dns', '--gpus' => 'gpus', '--hostname' => 'hostname', '--entrypoint' => 'entrypoint', diff --git a/tests/Feature/CommandInjectionSecurityTest.php b/tests/Feature/CommandInjectionSecurityTest.php index b327184a4..5fa5c08d2 100644 --- a/tests/Feature/CommandInjectionSecurityTest.php +++ b/tests/Feature/CommandInjectionSecurityTest.php @@ -733,6 +733,7 @@ '--entrypoint "sh -c \'npm start\'"', '--entrypoint "sh -c \'php artisan schedule:work\'"', '--hostname "my-host"', + '--dns 10.0.0.10 --dns=1.1.1.1', ]); }); diff --git a/tests/Feature/DockerCustomCommandsTest.php b/tests/Feature/DockerCustomCommandsTest.php index 74bff2043..299709ffd 100644 --- a/tests/Feature/DockerCustomCommandsTest.php +++ b/tests/Feature/DockerCustomCommandsTest.php @@ -46,6 +46,24 @@ ]); }); +test('ConvertDns', function () { + $input = '--dns 10.0.0.10 --dns=1.1.1.1'; + $output = convertDockerRunToCompose($input); + expect($output)->toBe([ + 'dns' => ['10.0.0.10', '1.1.1.1'], + ]); +}); + +test('ConvertDnsWithOtherOptions', function () { + $input = '--cap-add=NET_ADMIN --dns 10.0.0.10 --init'; + $output = convertDockerRunToCompose($input); + expect($output)->toBe([ + 'cap_add' => ['NET_ADMIN'], + 'dns' => ['10.0.0.10'], + 'init' => true, + ]); +}); + test('ConvertPrivilegedAndInit', function () { $input = '---privileged --init'; $output = convertDockerRunToCompose($input);