首先注册Dockerhub,创建repository
Username:daisyhxj
Passwd :
步骤一:tag and push the image,可以在本地看到标注自己的hello-world image
root@ubuntu-daisy:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest c54a2cc56cbb 10 weeksago 1.848 kB
root@ubuntu-daisy:~# docker tag c54a2cc56cbb daisyhxj/hello-world:latest
root@ubuntu-daisy:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
daisyhxj/hello-world latest c54a2cc56cbb 10 weeksago 1.848 kB
hello-world latest c54a2cc56cbb 10 weeksago 1.848 kB
docker tag命令格式:
1. Tells your operating system you are using the docker program
2.A subcommand that tags an image
3.The image ID
4.Your account name from Docker Hub / The image name : Version label or tag
1.docker 2.tag 3. c54a2cc56cbb 4. daisyhxj/hello-world:latest
步骤二: 在本地login Dockerhub
root@ubuntu-daisy:~# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.comto create one.
Username : daisyhxj
Password:
Login Succeeded
步骤三: push image 到Dockerhub repository
root@ubuntu-daisy:~# docker push daisyhxj/hello-world
The push refers to a repository[docker.io/daisyhxj/hello-world]
a02596fdd012: Mounted from library/hello-world
latest: digest: sha256:a18ed77532f6d6781500db650194e0f9396ba5f05f8b50d4046b294ae5f83aa4size: 524
现在可以登录网上Dockerhub 查看repository ,添加了daisyhxj/hello-world这个仓库
步骤四:pull image from Dockerhub
首先删除本地的hello-world image 及daisyhxj/hello-world image , 若要执行它,可以从hub上download
root@ubuntu-daisy:~# docker stop $(docker ps -a -q)
root@ubuntu-daisy:~# docker rmi -f c54a2cc56cbb
root@ubuntu-daisy:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
root@ubuntu-daisy:~# docker run daisyhxj/hello-world
Unable to find image 'daisyhxj/hello-world:latest' locally
latest: Pulling from daisyhxj/hello-world
c04b14da8d14: Pull complete
Digest:sha256:a18ed77532f6d6781500db650194e0f9396ba5f05f8b50d4046b294ae5f83aa4
Status: Downloaded newer image for daisyhxj/hello-world:latest
Hello from Docker!
This message shows that your installation appears to beworking correctly.
成功从hub上下载下来并执行