docker pull [OPTIONS] NAME[:TAG|@DIGEST]docker
若是不指定tag,默认选择latest标签;ubuntu
下载时会获取并输出镜像的各层信息,当不一样的镜像包括相同的层时,本地仅存一分内容,减少了须要的存储空间;bash
docker run -it ubuntu:latestspa
docker images3d
docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]blog
能够使用 --no-trunc 输出完整的命令input
搜查dockhu上的镜像dockerfile
docker rmi ubuntu:latestit
同一个镜像有多个标签时:只删除标签,不会删除镜像模板
同一个镜像只有一个标签时:删除镜像
当容器在使用镜像时,不建议使用-f删除镜像,正确的作法是先删除依赖改镜像的全部容器
三种方法:基于已有镜像的容器建立,基于本地模板导入、基于dockerfile
一、基于已有镜像的容器建立
docker run -it ubuntu:latest /bin/bash
docker commit -m "Added a new file" -a michael 0a973252a73e test:0.1
二、基于本地模板导入
导出镜像到本地
docker save -o ubunt14.tar ubuntu:latest
将导出的tar文件再倒入到本地仓库
docker load --input ubuntu14.tar
docker push <hub-user>/<repo-name>:<tag>