Handle cap_drop from container definitions

Signed-off-by: Fs00 <francescosaltori@gmail.com>
This commit is contained in:
Fs00
2026-04-25 18:46:48 +02:00
parent 6dc1cd6ebd
commit 43d8393a3b
3 changed files with 11 additions and 3 deletions
+2
View File
@@ -27,6 +27,8 @@ readonly class Container {
public bool $enableNvidiaGpu,
/** @var string[] */
public array $capAdd,
/** @var string[] */
public array $capDrop,
public int $shmSize,
public bool $apparmorUnconfined,
/** @var string[] */
+6
View File
@@ -298,6 +298,11 @@ readonly class ContainerDefinitionFetcher {
$capAdd = $entry['cap_add'];
}
$capDrop = [];
if (isset($entry['cap_drop'])) {
$capDrop = $entry['cap_drop'];
}
$shmSize = -1;
if (isset($entry['shm_size'])) {
$shmSize = $entry['shm_size'];
@@ -360,6 +365,7 @@ readonly class ContainerDefinitionFetcher {
$devices,
$enableNvidiaGpu,
$capAdd,
$capDrop,
$shmSize,
$apparmorUnconfined,
$backupVolumes,
+3 -3
View File
@@ -378,9 +378,9 @@ readonly class DockerActionManager {
$requestBody['HostConfig']['CapAdd'] = $capAdds;
}
// Disable arp spoofing
if (!in_array('NET_RAW', $capAdds, true)) {
$requestBody['HostConfig']['CapDrop'] = ['NET_RAW'];
$capDrops = $container->capDrop;
if (count($capDrops) > 0) {
$requestBody['HostConfig']['CapDrop'] = $capDrops;
}
// Disable SELinux for AIO containers so that it does not break them