2.docker镜像

(1)获取镜像

docker pull ARG NAME:[TAG]

NAME:镜像仓库的名称,TAG是镜像的标签

-a, --all-tags=true|false 是否获取仓库中的所有镜像,默认为否

例如: docker pull ubuntu:14.04

为了区分不同仓库服务器,可在镜像的仓库名称中添加注册服务器作为标示

例如:docker pull registry.hub.docker.com/ubuntu:14.04

(2)查看镜像信息

docker images ARG...

 -a,--all-true|false 列出所有的镜像文件

--digests=true|false 列出镜像的数字摘要值,默认为否

-f,--filter=[] 过滤列出的镜像

--no-trunc=false     不截断的输出(完整输出)ID信息

-q 仅输出ID信息

*为了方便后续使用,可以使用docker tag命令为本地镜像添加新的标签,类似软链接

 docker tag ubuntu:latest myubuntu:latest

*使用docker inspect NAME:TAG命令查看镜像的详细信息

-f, --format=      Format the output using the given go template

docker inspect -f {{".Container"}} ubuntu:latest

使用docker history images 查看镜像的创建过程

*docker search命令可以搜寻远端仓库中的共享信息

docker search ARG NAME

 --automated=false    仅显示自动创建的镜像
 
--no-trunc=false     不截断输出
  -s, --stars=x        只显示x及x星级以上的镜像

*删除镜像

docker rmi ARG E[IMAGE...]

-f, --force=false    Force removal of the image

--no-prune=false     Do not delete untagged parents

*创建镜像

docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

 -a, --author=       作者信息
 -c, --change=[]     提交的时候执行Dockerfile指令,包括CMD|ENTRYPOINT|ENVD等

 -m, --message=      Commit message 提交消息
-p, --pause=true    提交过程中暂停容器

例如: docker commit -m "Add a new file" -a "king" d775f72c38ba test:0.1

docker images
REPOSITORY           TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
test                 0.1                 e7625d73b582        3 seconds ago   

*由本地模板导入创建镜像

docker import [OPTIONS] URL|- [REPOSITORY[:TAG]]

cat ubuntu-14.04-x86_64-minimal.tar.gz |docker import - ubuntu:14.04

*存出镜像

docker save -o ubuntu_14.04.tar ubuntu:14.04

导入镜像

docker load -i ubuntu-14.04.tar

上传镜像

 docker push [OPTIONS] NAME[:TAG]

猜你喜欢

转载自www.cnblogs.com/soulmates/p/9237819.html