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