docker推送镜像(docker push)

背景

docker很方便的一点就是随时打包带走,搬家的时候连着房子一起搬走,不会有任何不适应不兼容。我在docker中部署了一个django应用,现在需要把它放在网上,便于以后下载和使用,这就用到docker push命令,这个命令可以联想到git命令的git push帮助记忆

操作

0.搜索并且打开dockerhub,没有注册则需要注册然后登录
1.在自己的docker hub中创建一个repository(库),这个库用来储存一系列的镜像(比如不同的更新版本)
docker推送镜像(docker push)
2.为一个repository进行命名比如我要命名test
docker推送镜像(docker push)
然后选择这个repository是公有(别人能看到和下载)还是私有(免费版只有一个库名额)

3.推送
首先查看当前的镜像
docker推送镜像(docker push)
然后给想要推送的镜像打标签(与repository一致)
dockers tag hello-world:latest xxx/test:v1
这里的xxx为自己的用户名,test为repository的名字,:v1表示版本。
之后推送即可
docker push xxx:test:v1