查看镜像
[root@docker-test1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/ubuntu 16.04 7aa3602ab41e 5 weeks ago 115 MB
docker commit :从容器创建一个新的镜像。
# docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
-a :提交的镜像作者;
-c :使用Dockerfile指令来创建镜像;
-m :提交时的说明文字;
-p :在commit时,将容器暂停。
根据这个myubuntu容器提交镜像
[root@docker-test1 ~]# docker commit -a "wangshibo" -m "this is test" 651a8541a47d myubuntu:v1
sha256:6ce4aedd12cda693d0bbb857cc443a56f9f569106e09ec61aa53563d0932ea4d
再次查看镜像,发现镜像myubuntu:v1已经提交到本地了
[root@docker-test1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
myubuntu v1 6ce4aedd12cd 59 seconds ago 84.1 MB
docker.io/ubuntu 16.04 7aa3602ab41e 5 weeks ago 115 MB
[root@docker-test1 ~]# docker push wangshibo/myubuntu:v1
The push refers to a repository [docker.io/wangshibo/myubuntu]
An image does not exist locally with the tag:docker.io/wangshibo/myubuntu
重点
这里需要将ubuntu:v1镜像改名,在名称前加上自己的docker hub的Docker ID,即wangshibo
[root@docker-test1 ~]# docker tag 6ce4aedd12cd wangshibo/myubuntu:v1
rm删除镜像
docker rmi 6ce4aedd12cd