前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >docker学习11-上传本地镜像到镜像仓库

docker学习11-上传本地镜像到镜像仓库

作者头像
上海-悠悠
发布2019-12-05 21:49:50
4.5K0
发布2019-12-05 21:49:50
举报

前言

在本地自己制作用过镜像后,上传到镜像仓库,这样方便在不同的机器上快速搭建同一套环境。 如果公开的话,别人也可以用你的镜像快速搭建环境,类似于 GitHub 本地代码上传到代码仓库,再从仓库拉取代码到本地。

新建镜像仓库

输入仓库名称和描述,可以选择公共 public 的仓库和私有 private 的仓库

创建成功后,右侧会提示使用docker push推送

docker push yoyo**/yoyo-pytest:tagname

本地镜像

本地镜像制作参考前面这篇https://www.cnblogs.com/yoyoketang/p/11397597.html

docker build -t yoyo_pytest:v1 .

代码语言:javascript
复制
[root@VM_0_2_centos docker-run]# docker build -t yoyo_pytest:v1 .
Sending build context to Docker daemon  3.072kB
Step 1/8 : FROM python:3.6.8
 ---> 48c06762acf0
Step 2/8 : MAINTAINER yoyo  <283340479@qq.com>
 ---> Using cache
 ---> e0835a3f4d47
Step 3/8 : RUN pip install --upgrade pip  --index-url https://pypi.douban.com/simple
 ---> Using cache
 ---> 0909be7567da
Step 4/8 : WORKDIR /code
 ---> Using cache
 ---> d006572cbc66
Step 5/8 : ADD . /code
 ---> Using cache
 ---> 7296a3b5c7fe
Step 6/8 : RUN pip install -r requirements.txt --index-url https://pypi.douban.com/simple
 ---> Using cache
 ---> ffa6afb30d19
Step 7/8 : ENTRYPOINT ["pytest"]
 ---> Using cache
 ---> d4da9935ba20
Step 8/8 : CMD ["--help"]
 ---> Using cache
 ---> 250e663c1097
Successfully built 250e663c1097
Successfully tagged yoyo_pytest:v1

docker build 镜像制作完成之后,查看本地镜像

代码语言:javascript
复制
[root@VM_0_2_centos docker-run]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
yoyo_pytest         v1                  250e663c1097        6 minutes ago       939MB

打本地标签tag

在上传之前,先给本地镜像打个tag标签,相当于重新复制镜像并重命名为docker账户名/仓库名称

docker tag 本地镜像:tag docker账号/docker仓库:tag

代码语言:javascript
复制
[root@VM_0_2_centos docker-run]# docker tag yoyo_pytest:v1  yoyo*****/yoyo-pytest
[root@VM_0_2_centos docker-run]# docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
yoyo/pytest                 latest              250e663c1097        30 minutes ago      939MB
yoyo*****/yoyo-pytest   latest              250e663c1097        30 minutes ago      939MB

push 上传本地镜像

先登陆docker hub账号,关于账号的注册和登陆查看上一篇https://www.cnblogs.com/yoyoketang/p/11923050.html

代码语言:javascript
复制
[root@VM_0_2_centos docker-run]# docker login
Authenticating with existing credentials...
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
[root@VM_0_2_centos docker-run]#

上传本地镜像标签到镜像仓库,使用docker指令

docker push docker 账号/仓库名称:tagname

代码语言:javascript
复制
[root@VM_0_2_centos docker-run]# docker push yoyo******/yoyo-pytest
The push refers to repository [docker.io/yoyo*********/yoyo-pytest]
6ec67a80257a: Pushed
d8f6dad5fd38: Pushed
08f4f1010d69: Pushed
3b08987fd99a: Pushed
d03a0ab13129: Pushed
02d7555642f3: Pushed
b04c763f3532: Pushed
24747797d2fa: Pushed
a637c551a0da: Pushed
2c8d31157b81: Pushed
7b76d801397d: Pushed
f32868cde90b: Pushed
0db06dff9d9a: Pushed
latest: digest: sha256:35f815bd6169c75f998a894a664d850abfae5c5c99cbcc80881cb123f777754e size: 3054

上传完成后打开自己的docker hub账号,查看镜像仓库

pull 拉取镜像

拉取镜像使用docker pull 你自己的镜像名称

docker pull yoyo**/yoyo-pytest

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2019-11-24,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 从零开始学自动化测试 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 前言
  • 新建镜像仓库
  • 本地镜像
  • 打本地标签tag
  • push 上传本地镜像
  • pull 拉取镜像
相关产品与服务
容器镜像服务
容器镜像服务(Tencent Container Registry,TCR)为您提供安全独享、高性能的容器镜像托管分发服务。您可同时在全球多个地域创建独享实例,以实现容器镜像的就近拉取,降低拉取时间,节约带宽成本。TCR 提供细颗粒度的权限管理及访问控制,保障您的数据安全。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档