I’ve found it out when I had a lucky streak with moby’s source code. Details answered here: https://stackoverflow.com/a/63219871
bottom line: order of cap add and drop is hardcoded (YAML doesn’t define any, thus same for CLI args), but varies depending on especially ALL. First matching case below terminates.
- container is
privileged: true
: ignorecap_add
andcap_drop
completely, return all available capabilities instead. - both
cap_add
andcap_drop
are empty : return the default Docker set of capabilities. -
cap_add
containsALL
: return all capabilities minus the capabilities listed incap_drop
(ignoresALL
in the latter). -
cap_drop
containsALL
: return the capabilities fromcap_add
only, ignoring any Docker default capabilities. - default: first drop all capabilites from the default set listed in
cap_drop
, then add the capabilities incap_add
, and finally return the result.