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_addandcap_dropcompletely, return all available capabilities instead. - both
cap_addandcap_dropare empty : return the default Docker set of capabilities. -
cap_addcontainsALL: return all capabilities minus the capabilities listed incap_drop(ignoresALLin the latter). -
cap_dropcontainsALL: return the capabilities fromcap_addonly, 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.