1.Docker镜像
Docker运行容器前需要本地存在对应的镜像,如果镜像不存在,会尝试从远端进行仓库中拉取
1.1 拉取镜像
docker image pull name:tag
docker pull name:tag
docker pull hello-world:latest

1.2 查看镜像列表
docker images
docker image ls
docker images -aq
 字段说明:
- REPOSITORY:来自于哪个仓库
- TAG:表示版本信息
- IMAGE ID:镜像的id,是镜像的唯一标识,如果两个镜像的ID一样,说明它们实际上指向了同一个镜像,只是具有不同的标签名称而已
- CREATED:镜像最后的更新时间
- SIZE:镜像的大小
1.3 删除镜像
docker image rm [image id] [image id]
docker image rm -f [image id]
docker image prune
1.4 创建镜像
1.基于已有的容器创建
docker container commit -m "test create image" 0714643ba560 my-world:2.0
 2.基于Dockerfile创建
Dockerfile第一个文本文件,利用给定的指令描述基于某个父镜像创建新镜像的过程
1.5 docker镜像命令

使用docker image tag可以为本地镜像创建新的tag,但是它们的镜像id都是一样的 
2.Docker容器
容器是镜像的一个运行实例
2.1 新建容器
docker create -it my-world:2.0
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bec37ce844b8 my-world:2.0 "/hello" 2 minutes ago Created
2.2 运行容器
docker start [container id]
2.3 停止容器
docker stop [container id]
2.4 进入容器
docker exec -it [container id] bash
2.5 查看容器
docker inspect [container id]
最后,欢迎关注微信公众号一起交流

|