Docker常用命令(二)

1. 卷

1.1 创建卷

docker volume create --driver local --label example=location location-example

local是一个创建卷的插件引擎

example=llocation是标签的key和value

localtion-example是创建的卷的名字

1.2 检查卷在主机文件系统树中的位置

docker volume inspect --format "{{json .Mountpoint}}" location-example

1.3 删除卷

docker volume remove location-example

1.4 列出所有的卷

docker volume list

1.5 清除所有没有被使用的卷

docker volume prune (--filter label_name=label_value)

--filter 可以只删除指定label的卷,如1.1中创建的卷的label为example=location

2. 网络

2.1 查看可用的网络

docker network ls

2.2 创建网络

docker network create [] $networkName

[]中为如下参数

驱动 --driver bridge

标签 --label project=myProjectr

可连接 --attachable

网络范围 --scope local

子网掩码和可分配的IP范围 --subnet 10.0.42.0/42 --ip-range 10.0.42.128/25

2.3 将容器连接到网络

docker network connect $netName $containerName

3 容器查看命令

3.1 查看容器的卷

docker inspect --format "{{json .Mounts}}" $containerName

3.2 查看镜像定义的运行时用户

docker inspect --format "{{.Config.User}}" $containerName

3.3 连接到容器终端

docker attach $containerName

3.4 进入容器

docker exec -it $containerName bash

3.5 执行命令

docker exec $containerName $shell

3.6 查看容器应用日志

docker logs $containerName

-f 查看实时日志

3.7 显示容器种每个进程的主机PID

docker top $containerName

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值