How to run script in docker container with additional capabilities (docker exec … --cap-add …)
问题 How can I run a script in a docker container with additional capabilities, such as NET_ADMIN ? I'm testing out some commands that I'd like to run in a docker image that require the NET_ADMIN permissions. For example, this works: docker run --rm -it --cap-add 'NET_ADMIN' debian:stable-slim "iptables -L" But if I want to execute a script (via docker exec ), then suddenly the --cap-add option is not available. root@disp8686:~# cat << EOF > docker_script.sh > apt-get update > apt-get -y install