Docker CLI
Docker CLI:随着Docker架构的调整,一个管理命令对应一个子业务的范畴。
builder 镜像的构建管理
docker builder prune: 清除构建中的缓存
-a, --all Remove all unused images, not just dangling ones
--filter filter Provide filter values (e.g. 'unused-for=24h')
-f, --force Do not prompt for confirmation
--keep-storage bytes Amount of disk space to keep for cache
config 配置文件管理
子命令:
create Create a config from a file or STDIN
inspect Display detailed information on one or more configs
ls List configs
rm Remove one or more configs
container 容器管理
Commands:
attach Attach local standard input, output, and error streams to a running container
//现在一般用exec来执行,attach quit的时候,容器也会终止
commit Create a new image from a container's changes
//基于容器321,创建一个mycentos的镜像、tag为“first”:docker container commit web321 mycentos:first
cp Copy files/folders between a container and the local filesystem
// 拷贝test.txt文件,到容器web321的/root目录下面: docker container cp test.txt web321:/root
create Create a new container
//基于镜像,创建today3_centos的容器:docker container create --tty --interactive --name today3_centos centos
diff Inspect changes to files or directories on a container's filesystem
exec Run a command in a running container
//进入web321的容器,如docker container exec -it web321 bash
export Export a container's filesystem as a tar archive
inspect Display detailed information on one or more containers
// 显示web321容器的信息, docker container inspect web321
kill Kill one or more running containers
logs Fetch the logs of a container
ls List containers
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
prune Remove all stopped containers
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
run Run a command in a new container
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
wait Block until one or more containers stop, then print their exit codes
engine Docker Engine管理
对Docker engine的企业版本激活、检查有哪些较新的版本、更新Docker engine版本
Commands:
activate Activate Enterprise Edition
check Check for available engine updates
update Update a local engine
image 镜像管理
Usage: docker image COMMAND
Commands:
build Build an image from a Dockerfile
history Show the history of an image
import Import the contents from a tarball to create a filesystem image
inspect Display detailed information on one or more images
load Load an image from a tar archive or STDIN
ls List images
prune Remove unused images
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rm Remove one or more images
save Save one or more images to a tar archive (streamed to STDOUT by default)
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
//修改镜像文件的centos:latest为centos:today: docker image tag centos:latest centos:today
network 网络管理
1、 安装docker Engine时,会自动创建一个默认的bridge网络docker0。
2、可以创建自己的bridge网络或overlay网络。
3、overlay 网络驱动程序在多个 Docker 守护进程主机之间创建一个分布式网络。
这个网络在允许容器连接、并进行安全通信的主机专用网络之上(overlay 覆盖在上面)。Docker 透明地处理每个 Docker 守护进程与目标容器之间的数据包的路由
Usage: docker network COMMAND
Manage networks
Commands:
connect Connect a container to a network
create Create a network
disconnect Disconnect a container from a network
inspect Display detailed information on one or more networks
ls List networks
prune Remove all unused networks
rm Remove one or more networks
volume volumes管理
volumes相当于一个目录,在docker容器和宿主主机之间共享数据。
Usage: docker volume COMMAND
Manage volumes
Commands:
create Create a volume
inspect Display detailed information on one or more volumes
ls List volumes
prune Remove all unused local volumes
rm Remove one or more volumes
system Manage Docker
Usage: docker system COMMAND
查看docker 宿主主机的磁盘使用情况,对事件进行监控、系统的信息、清除不使用的数据。
Manage Docker
Commands:
df Show docker disk usage
events Get real time events from the server
info Display system-wide information
prune Remove unused data
其它命令
下面是集群、安全的相关管理,暂略。
node Swarm节点管理
plugin 插件管理
secret Manage Docker secrets
service Manage services
stack Manage Docker stacks
swarm Manage Swarm
trust Manage trust on Docker images