docker中--privileged的使用

#### 前言

--privileged可以满足我们的定制化需求

 

#### 作用

- 使container内的root拥有真正的root权限,否则只是外部的一个普通用户权限

- 可以看到很多host上的设备,并且可以执行mount

- 允许你在docker容器中启动docker容器

 

#### 示例

> docker run -it --privileged=true centos bash

```

[root@c14a0aa72797 /]# ls /dev/
autofs         loop-control         snd     tty22  tty41  tty60    vcs2
bsg         mapper             sr0     tty23  tty42  tty61    vcs3
btrfs-control     mcelog             stderr  tty24  tty43  tty62    vcs4
bus         mem             stdin   tty25  tty44  tty63    vcs5
console         mqueue             stdout  tty26  tty45  tty7     vcs6
core         net             tty     tty27  tty46  tty8     vcsa
cpu         network_latency     tty0    tty28  tty47  tty9     vcsa1
cpu_dma_latency  network_throughput  tty1    tty29  tty48  ttyS0    vcsa2
crash         null             tty10   tty3   tty49  ttyS1    vcsa3
dm-0         nvram             tty11   tty30  tty5   ttyS2    vcsa4
dm-1         oldmem             tty12   tty31  tty50  ttyS3    vcsa5
dri         port             tty13   tty32  tty51  uhid     vcsa6
fb0         ppp             tty14   tty33  tty52  uinput   vda
fd         ptmx             tty15   tty34  tty53  urandom  vda1
full         pts             tty16   tty35  tty54  usbmon0  vda2
fuse         random             tty17   tty36  tty55  usbmon1  vfio
hidraw0         raw             tty18   tty37  tty56  usbmon2  vga_arbiter
hpet         rtc0             tty19   tty38  tty57  usbmon3  vhci
hwrng         sg0             tty2    tty39  tty58  usbmon4  vhost-net
input         shm             tty20   tty4   tty59  vcs        vport1p1
kmsg         snapshot         tty21   tty40  tty6   vcs1     zero
[root@c14a0aa72797 /]# mkdir /home/test1
[root@c14a0aa72797 /]# mkdir /home/test2
[root@c14a0aa72797 /]# mount -o bind /home/test1 /home/test2

```

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值