1. image 镜像
命令 |
含义 |
语法 |
案例 |
ls |
查看全部镜像 |
docker image ls |
|
search |
查找镜像 |
docker search [imageName] |
|
history |
查看镜像历史 |
docker history [imageName] |
|
inspect |
显示一个或多个镜像详细信息 |
docker inspect [imageName] |
|
pull |
拉取镜像 |
docker pull [imageName] |
|
push |
推送一个镜像到镜像仓库 |
docker push [imageName] |
|
rmi |
删除镜像 |
docker rmi [imageName] docker image rmi 2 |
|
prune |
移除未使用的镜像,没有标记或补任何容器引用 |
docker image prune |
docker image prune |
tag |
标记本地镜像,将其归入某一仓库 |
docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG] |
docker tag centos:7 zhangrenyang/centos:v1 |
export |
将容器文件系统作为一个 tar 归档文件导出到 STDOUT |
docker export [OPTIONS] CONTAINER |
docker export -o hello-world.tar b2712f1067a3 |
import |
导入容器快照文件系统 tar 归档文件并创建镜像 |
docker import [OPTIONS] file/URL/- [REPOSITORY[:TAG]] |
docker import hello-world.tar |
save |
将指定镜像保存成tar 文件 |
docker save [OPTIONS] IMAGE [IMAGE…] |
docker save -o hello-world.tar hello-world:latest |
load |
加载 tar 文件并创建镜像 |
|
docker load -i hello-world.tar |
build |
根据 Dockerfile 构建镜像 |
docker build [OPTIONS] PATH / URL / - |
docker build -t zf/ubuntu:v1 . |
docker image ls
docker search ubuntu
docker pull docker.io/hello-world
docker image pull docker.io/hello-world
docker rmi hello-world
docker export -o [新输入镜像的名称] [容器ID]
2. container 容器
常用命令
docker --help
docker run ubuntu /bin/echo "Hello world"# Docker以ubuntu镜像创建一个新容器,然后在容器里执行 bin/echo "Hello world",然后输出结果
docker run -d -p 1010:80 -e username="ghx" --name ghx-nginx nginx
docker container exec -it 3695dc5b9c2d /bin/bash
docker ps
docker ps -a
docker ps -l
docker ps -a -q
docker inspect [containerId]
docker run -i -t ubuntu /bin/bash
docker run -d -p 8080:80 nginx
exit
docker run -d centos ping www.baidu.com
docker logs --follow [containerId]
docker kill [containerId]
docker rm [containerId]
docker rmi [imageId]
docker rm $(docker ps -a -q)
docker start [containerId]
docker stop [containerId]
docker attach [containerID]
docker exec -it [containerID] /bin/bash
docker container cp f6a53629488b:/root/root.txt .
docker run --rm ubuntu /bin/bash
docker container stats
docker update -m 500m [containerID]
docker run -d -p 8080:80 nginx
docker container port containerID
docker logs [containerId]
docker logs -f [containerId]