1、首先注册Docker账号。请参考官网地址,如下,截图位置的连接。
2、填写用户名、邮箱和密码,会发送一封验证邮件,验证后就ok了。
3、登陆docker账号:docker login
4、Tag the image:标记镜像。推荐方式:docker tag image username/repository:tag例如:docker tag friendlyhello xiayuxue/get-started:part2
5、Publish the image:发布镜像,上传到远程仓库。(这个和maven很像)命令:docker push xiayuxue/get-started:part2登陆Docker账号,可以看到自己上传的镜像。
6、Pull and run the image from the remote repository:从远程拉胃申赜驵取镜像,并运行。命令:docker run -p 4000:80 xiayuxue/get-started:part2发现并没有从远程下载,是因为本地仓库中就有这个镜像,要模拟这种情况,就得重新开一个虚拟机,安装Docker,然后运行此命令。尝试删除这个镜像,但是删除不了,意思是说已经上传到远程了。