在docker container中执行命令时出现了权限问题
1 2 | set_mempolicy: operation not permitted setting membind: operation not permitted |
privileged参数
使用该参数,container内的root拥有真正的root权限。
否则,container内的root只是外部的一个普通用户权限。
1 2 | root@mlt-bddl12:~# docker run --help --privileged Give extended privileges to this container |
未设置privileged启动的容器:
1 2 3 4 5 6 7 | root@mlt2-clx251:~# docker run -t -i centos:7 bash [root@d785892aa4a5 /]# ls /dev console core fd full mqueue null ptmx pts random shm stderr stdin stdout tty urandom zero [root@d785892aa4a5 /]# mkdir test1 [root@d785892aa4a5 /]# mkdir test2 [root@d785892aa4a5 /]# mount -o build /test1 /test2 mount: permission denied |
设置privileged启动的容器:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | root@mlt2-clx251:~# docker run -t -i --privileged centos:7 bash [root@8746b54b33c0 /]# ls /dev autofs hpet mcelog random tty11 tty27 tty42 tty58 ttyS15 ttyS30 vcs3 vcsu6 bsg hwrng mei0 rfkill tty12 tty28 tty43 tty59 ttyS16 ttyS31 vcs4 vfio btrfs-control i2c-0 mem rtc0 tty13 tty29 tty44 tty6 ttyS17 ttyS4 vcs5 vga_arbiter bus input memory_bandwidth sda tty14 tty3 tty45 tty60 ttyS18 ttyS5 vcs6 vhci console ipmi0 mqueue sda1 tty15 tty30 tty46 tty61 ttyS19 ttyS6 vcsa vhost-net core kmsg net sda2 tty16 tty31 tty47 tty62 ttyS2 ttyS7 vcsa1 vhost-vsock cpu lightnvm network_latency sg0 tty17 tty32 tty48 tty63 ttyS20 ttyS8 vcsa2 zero cpu_dma_latency loop-control network_throughput shm tty18 tty33 tty49 tty7 ttyS21 ttyS9 vcsa3 zfs cuse loop0 null snapshot tty19 tty34 tty5 tty8 ttyS22 ttyprintk vcsa4 dri loop1 nvram snd tty2 tty35 tty50 tty9 ttyS23 udmabuf vcsa5 ecryptfs loop2 port stderr tty20 tty36 tty51 ttyS0 ttyS24 uhid vcsa6 fb0 loop3 ppp stdin tty21 tty37 tty52 ttyS1 ttyS25 uinput vcsu fd loop4 psaux stdout tty22 tty38 tty53 ttyS10 ttyS26 urandom vcsu1 full loop5 ptmx tty tty23 tty39 tty54 ttyS11 ttyS27 userio vcsu2 fuse loop6 ptp0 tty0 tty24 tty4 tty55 ttyS12 ttyS28 vcs vcsu3 hidraw0 loop7 ptp1 tty1 tty25 tty40 tty56 ttyS13 ttyS29 vcs1 vcsu4 hidraw1 mapper pts tty10 tty26 tty41 tty57 ttyS14 ttyS3 vcs2 vcsu5 [root@8746b54b33c0 /]# mkdir test1 [root@8746b54b33c0 /]# mkdir test2 [root@8746b54b33c0 /]# mpunt -o build /test1 /test2 mount: /test1 is not a block device |