Usage: docker tag IMAGE[:TAG] IMAGE[:TAG]
Tag an image into a repository
Options:
--help Print usage
一个镜像名称由以斜杠分隔的名称组件组成,及可选的主机名前缀。主机名必须符合标准的DNS规则,不过不能包含下划线。如果名称存在主机名,可以在其后面加一个端口号,格式为:8080。没有不存在主机名,命令就使用默认的docker公共registryregistry-1.docker.io。名称组件可以包含小写字符,数字和分隔符。分隔符可以是句点,一个或两个下划线或一个或多个破折号。
一个名称组件不能以分隔符开始或结束。
tag名称可以包含小写字符和大写字符,数字,下划线,名点和破折号。tag名称不能以名点或破折号开头,且最大支持128个字符。
示例
通过ID tag镜像
下面是tag一个id为0e5574283393的本地镜像到“fedora”存储库,tag名称version1.0:
docker tag 0e5574283393 fedora/httpd:version1.0
通过名称tag镜像
使用名称“httpd” tag本地镜像到存储库”fedora”,且其tag名为version1.0
docker tag httpd fedora/httpd:version1.0
注意由于引用httpd的tag名称没有指定,默认引用httpd:latest。
通过名称和tag名称tag一个镜像
为名称为httpd和tag名称为test的本地镜像做标签,其存储库为fedora,标签名为version1.0.test。
docker tag httpd:test fedora/httpd:version1.0.test
tag一个镜像到私有的存储库
要推送一个镜像到一个私有的registry,而不是公共的docker registry,必须指定一个registry主机名和端口来tag此镜像。
docker tag 0e5574283393 myregistryhost:5000/fedora/httpd:version1.0
commit 一个新的之后,老的如果有重名就会直接变成<none>的
https://www.v2ex.com/t/229142
删除none的镜像,要先删除镜像中的容器。要删除镜像中的容器,必须先停止容器。
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE <none> <none> 168b258ceea3 34 seconds ago 460.6 MB <none> <none> b2c5d34941c6 23 minutes ago 588.7 MB tankzhang/es v1 85fc66558c37 13 days ago 352.1 MB elasticsearch latest d781cd4e3228 3 weeks ago 352.1 MB centos latest 8140d0c64310 3 weeks ago 192.6 MB hello-world latest 48b5124b2768 4 months ago 1.84 kB tankzhang/es v2 48b5124b2768 4 months ago 1.84 kB $ docker rmi $(docker images | grep "none" | awk '{print $3}') Error response from daemon: conflict: unable to delete b2c5d34941c6 (must be forced) - image is being used by stopped container ad0032609294 Error response from daemon: conflict: unable to delete 168b258ceea3 (must be forced) - image is being used by stopped container 1b7067e19d6f
直接删除带none的镜像,直接报错了。提示先停止容器。
$ docker stop $(docker ps -a | grep "Exited" | awk '{print $1 }') //停止容器 1b7067e19d6f a840f345c423 9d74eff1c4e4 17d361107a21 dd51ead96da7 ad0032609294 95e713ab1bdf $ docker rm $(docker ps -a | grep "Exited" | awk '{print $1 }') //删除容器 1b7067e19d6f a840f345c423 9d74eff1c4e4 17d361107a21 dd51ead96da7 ad0032609294 95e713ab1bdf $ docker rmi $(docker images | grep "none" | awk '{print $3}') //删除镜像 Deleted: sha256:168b258ceea3f5ee9d7f066e04c89c4858f0e337687f18b5939a78aea13ea6c8 Deleted: sha256:d3984014bcbe856f569dcade31ce70aae8cc5ead3806e47ae08229467c9ed3ca Deleted: sha256:b2c5d34941c646a1962d2acd9ff968708495a82916c33797f5fb3d94de403c6d Deleted: sha256:5a23f5ad9107bb1111f32d490982e2146cf0811c8b75c7a6cd67ca45fc2f50dd Deleted: sha256:392d616344b17b0bb7b8ad46cc9a8c6f5ab4be8bd59c3d5973016e8759a1668c Deleted: sha256:33fbf9c999e8beac51b184a0f2baeaf1a2b99b10c4cc1f654075af42779fb62e Deleted: sha256:b3535d64be668cd7e3389c4da224ae6e3aaedadff05ed24f428fc83e96c65a03 Deleted: sha256:da47261567b38193ba4894e7c832d9eba78d9cc3a501101ebf5fd7304efef5b9 Deleted: sha256:b81b2578fd4e803fac0bd416e606362ed14432370088eba8bf5c43a4fca8f7ed Deleted: sha256:6f4b2f9fd5be471ac80c599c9616feaaf3952ce8a68d5d8c26645bfaff7aae4a
Deleted: sha256:480e2b77d27aea6e128db8d3c400f37b74da1b365b0eb663022d7208a9694209
共同学习,写下你的评论
评论加载中...
作者其他优质文章