title: Invoking iptables results in "operation not supported" in docker
body: <p>I'm running into an error when using <code>iptables</code> within a pod:</p>
  
  <pre><code>root@chris-sshuttle-k8stest:~# iptables -t nat -nL
  iptables: Operation not supported.
  </code></pre>
  
  <hr>
  
  <p>If I run the image directly with docker though it works correctly:</p>
  
  <pre><code>docker run --cap-add=NET_ADMIN -it --rm chrissound/sshuttle-k8stest:v2 /bin/bash
  root@e857b0d4152a:/# iptables -t nat -nL
  Chain PREROUTING (policy ACCEPT)
  target     prot opt source               destination         
  ...
  </code></pre>
  
  <p>In addition the output of <code>capsh --print</code> is:</p>
  
  <pre><code>root@chris-sshuttle-k8stest:~# capsh --print
  Current: = cap_chown,cap_dac_override,cap_dac_read_search,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_linux_immutable,cap_net_bind_service,cap_net_broadcast,cap_net_admin,cap_net_raw,cap_ipc_lock,cap_ipc_owner,cap_sys_module,cap_sys_rawio,cap_sys_chroot,cap_sys_ptrace,cap_sys_pacct,cap_sys_admin,cap_sys_boot,cap_sys_nice,cap_sys_resource,cap_sys_time,cap_sys_tty_config,cap_mknod,cap_lease,cap_audit_write,cap_audit_control,cap_setfcap,cap_mac_override,cap_mac_admin,cap_syslog,cap_wake_alarm,cap_block_suspend,cap_audit_read+eip
  Bounding set =cap_chown,cap_dac_override,cap_dac_read_search,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_linux_immutable,cap_net_bind_service,cap_net_broadcast,cap_net_admin,cap_net_raw,cap_ipc_lock,cap_ipc_owner,cap_sys_module,cap_sys_rawio,cap_sys_chroot,cap_sys_ptrace,cap_sys_pacct,cap_sys_admin,cap_sys_boot,cap_sys_nice,cap_sys_resource,cap_sys_time,cap_sys_tty_config,cap_mknod,cap_lease,cap_audit_write,cap_audit_control,cap_setfcap,cap_mac_override,cap_mac_admin,cap_syslog,cap_wake_alarm,cap_block_suspend,cap_audit_read
  Securebits: 00/0x0/1'b0
   secure-noroot: no (unlocked)
   secure-no-suid-fixup: no (unlocked)
   secure-keep-caps: no (unlocked)
  uid=0(root)
  gid=0(root)
  groups=
  </code></pre>
  
  <p>Which does have <code>net_admin</code>:</p>
  
  <pre><code>root@chris-sshuttle-k8stest:~# capsh --print | grep net_admin
  Current: = cap_chown,cap_dac_override,cap_dac_read_search,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_linux_immutable,cap_net_bind_service,cap_net_broadcast,cap_net_admin,cap_net_raw,cap_ipc_lock,cap_ipc_owner,cap_sys_module,cap_sys_rawio,cap_sys_chroot,cap_sys_ptrace,cap_sys_pacct,cap_sys_admin,cap_sys_boot,cap_sys_nice,cap_sys_resource,cap_sys_time,cap_sys_tty_config,cap_mknod,cap_lease,cap_audit_write,cap_audit_control,cap_setfcap,cap_mac_override,cap_mac_admin,cap_syslog,cap_wake_alarm,cap_block_suspend,cap_audit_read+eip
  Bounding set =cap_chown,cap_dac_override,cap_dac_read_search,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_linux_immutable,cap_net_bind_service,cap_net_broadcast,cap_net_admin,cap_net_raw,cap_ipc_lock,cap_ipc_owner,cap_sys_module,cap_sys_rawio,cap_sys_chroot,cap_sys_ptrace,cap_sys_pacct,cap_sys_admin,cap_sys_boot,cap_sys_nice,cap_sys_resource,cap_sys_time,cap_sys_tty_config,cap_mknod,cap_lease,cap_audit_write,cap_audit_control,cap_setfcap,cap_mac_override,cap_mac_admin,cap_syslog,cap_wake_alarm,cap_block_suspend,cap_audit_read
  </code></pre>
  
  <p>pod.yaml:</p>
  
  <pre><code>apiVersion: v1
  kind: Pod
  metadata:
    name: chris-sshuttle-k8stest
    labels:
      name: chris-sshuttle-k8stest 
  spec:
    containers:
    - name: sshuttle
      image: chrissound/sshuttle-k8stest:v2
      command: ["sleep", "10000000"]
      securityContext:
        privileged: true
        capabilities:
          add: ["NET_ADMIN","NET_RAW"]
  </code></pre>
  
  <hr>
  
  <p>Extra debugging:</p>
  
  <p>SSHing to the k8s node and inspecting the docker container everything seems to be correct:</p>
  
  <pre><code>$ docker inspect 6f96802d7e13 | grep -B 4 -A 4 NET_AD
              "AutoRemove": false,
              "VolumeDriver": "",
              "VolumesFrom": null,
              "CapAdd": [
                  "NET_ADMIN",
                  "NET_RAW"
              ],
              "CapDrop": null,
              "Dns": null,
  </code></pre>