前言

系统环境:Centos7、jdk1.8

docker私服:可以把项目通过dockerfile文件build成docker镜像,供其他环境拉取。部署在本地,私有化。

安装

dockerHUB私服

1. 搭建registry

  1. #拉取registry镜像
  2. [root@localhost home]# docker pull registry
  3. Using default tag: latest
  4. latest: Pulling from library/registry
  5. c87736221ed0: Pull complete
  6. 1cc8e0bb44df: Pull complete
  7. 54d33bcb37f5: Pull complete
  8. e8afc091c171: Pull complete
  9. b4541f6d3db6: Pull complete
  10. Digest: sha256:8004747f1e8cd820a148fb7499d71a76d45ff66bac6a29129bfdbfdc0154d146
  11. Status: Downloaded newer image for registry:latest
  12.  
  13. #查看镜像
  14. [root@localhost home]# docker images
  15. REPOSITORY TAG IMAGE ID CREATED SIZE
  16. registry latest f32a97de94e1 6 months ago 25.8MB
  17.  
  18. #启动容器
  19. [root@localhost home]# docker run -d -v /data/registry:/var/lib/registry -p 5000:5000 --restart=always --name qdockerhub registry:latest
  20. 67b0ac40561688b8bb874fa9674e44eb069cc6ee443127ba80b140ea51947af7
  21.  
  22. #测试/v2/_catalog接口
  23. [root@localhost home]# curl http://127.0.0.1:5000/v2/_catalog
  24. {"repositories":[]}
  25. [root@localhost home]#

2. 提交镜像

  1. #拉取tomcat测试提交
  2. [root@localhost home]# docker pull tomcat
  3. Using default tag: latest
  4. latest: Pulling from library/tomcat
  5. 092586df9206: Pull complete
  6. ef599477fae0: Pull complete
  7. 4530c6472b5d: Pull complete
  8. d34d61487075: Pull complete
  9. 272f46008219: Pull complete
  10. 12ff6ccfe7a6: Pull complete
  11. f26b99e1adb1: Pull complete
  12. 21bec9c8ea28: Pull complete
  13. e2f6023231f2: Pull complete
  14. c47eb491a5e3: Pull complete
  15. Digest: sha256:74e52cc6d27dacb079b273c129d6bf32df6ba328d6508b81ef65f41675ae9570
  16. Status: Downloaded newer image for tomcat:latest
  17.  
  18. #查看镜像
  19. [root@localhost home]# docker images
  20. REPOSITORY TAG IMAGE ID CREATED SIZE
  21. tomcat latest 365b0a528e2e 4 days ago 506MB
  22. registry latest f32a97de94e1 6 months ago 25.8MB
  23.  
  24. #给镜像重命名,ip:端口/镜像名称
  25. [root@localhost home]# docker tag tomcat:latest 127.0.0.1:5000/testtomcat
  26.  
  27. #再次查看镜像
  28. [root@localhost home]# docker images
  29. REPOSITORY TAG IMAGE ID CREATED SIZE
  30. 127.0.0.1:5000/testtomcat latest 365b0a528e2e 4 days ago 506MB
  31. tomcat latest 365b0a528e2e 4 days ago 506MB
  32. registry latest f32a97de94e1 6 months ago 25.8MB
  33.  
  34. #提交镜像到到docker私服
  35. [root@localhost home]# docker push 127.0.0.1:5000/testtomcat
  36. The push refers to repository [127.0.0.1:5000/testtomcat]
  37. 4a3ccf95eef9: Pushed
  38. 4437177a7bda: Pushed
  39. 5161954b2663: Pushed
  40. 57e6a3d20ce9: Pushed
  41. 1690af51cb08: Pushed
  42. 5a30999619d7: Pushed
  43. 2e669e0134f5: Pushed
  44. 8bacec4e3446: Pushed
  45. 26b1991f37bd: Pushed
  46. 55e6b89812f3: Pushed
  47. latest: digest: sha256:416e93b104aa4bceff6005ec6cc4e073196f98d8e3aa4564c3f7d6ad3591d767 size: 2422
  48.  
  49. #curl验证
  50. [root@localhost home]# curl http://127.0.0.1:5000/v2/_catalog
  51. {"repositories":["testtomcat"]}

3. 拉取镜像

  1. #查看镜像
  2. [root@localhost home]# docker images
  3. REPOSITORY TAG IMAGE ID CREATED SIZE
  4. registry latest f32a97de94e1 6 months ago 25.8MB
  5.  
  6. #拉取docker私服镜像
  7. [root@localhost home]# docker pull 127.0.0.1:5000/testtomcat
  8. Using default tag: latest
  9. latest: Pulling from testtomcat
  10. 092586df9206: Pull complete
  11. ef599477fae0: Pull complete
  12. 4530c6472b5d: Pull complete
  13. d34d61487075: Pull complete
  14. 272f46008219: Pull complete
  15. 12ff6ccfe7a6: Pull complete
  16. f26b99e1adb1: Pull complete
  17. 21bec9c8ea28: Pull complete
  18. e2f6023231f2: Pull complete
  19. c47eb491a5e3: Pull complete
  20. Digest: sha256:416e93b104aa4bceff6005ec6cc4e073196f98d8e3aa4564c3f7d6ad3591d767
  21. Status: Downloaded newer image for 127.0.0.1:5000/testtomcat:latest
  22.  
  23. #再次查看镜像
  24. [root@localhost home]# docker images
  25. REPOSITORY TAG IMAGE ID CREATED SIZE
  26. 127.0.0.1:5000/testtomcat latest 365b0a528e2e 4 days ago 506MB
  27. registry latest f32a97de94e1 6 months ago 25.8MB

4.删除私服镜像

  1. # 查看当前docker私服中的镜像
  2. [root@localhost ~]# curl http://127.0.0.1:5000/v2/_catalog
  3. {"repositories":["mingbytesiteweb"]}
  4.  
  5. # 查看docker私服容器,重点是 CONTAINER ID
  6. [root@localhost ~]# docker ps
  7. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  8. 67b0ac405616 registry:latest "/entrypoint.sh /etc…" 44 hours ago Up 44 hours 0.0.0.0:5000->5000/tcp qdockerhub
  9.  
  10. # 删除docker私服中的“mingbytesiteweb”镜像
  11. # 其中67b0ac405616 为docker私服容器id
  12. [root@localhost ~]# docker exec 67b0ac405616 rm -rf /var/lib/registry/docker/registry/v2/repositories/mingbytesiteweb
  13.  
  14. # 清除掉blob
  15. # 67b0为docker私服容器id
  16. [root@localhost ~]# docker exec 67b0 bin/registry garbage-collect /etc/docker/registry/config.yml
  17.  
  18. 0 blobs marked, 9 blobs and 0 manifests eligible for deletion
  19. blob eligible for deletion: sha256:a381f92f36de52ade5b5610ef1b354713f21902b2ef32abf8f5101daf686e6b4
  20. blob eligible for deletion: sha256:cce6b5d4a535e729c30f1f9140a61e5fe408250c442ad69569612094970f8035
  21. blob eligible for deletion: sha256:d5c237920c394bda8bf1ef31b00bbde458f6978c159303e00d712a95c3f32a40
  22. time="2019-09-20T02:53:41.576433178Z" level=info msg="Deleting blob: /docker/registry/v2/blobs/sha256/a3/a381f92f36de52ade5b5610ef1b354713f21902b2ef32abf8f5101daf686e6b4" go.version=go1.11.2 instance.id=ded69299-53f9-4ffe-9309-a707264a7549 service=registry
  23. time="2019-09-20T02:53:41.576740825Z" level=info msg="Deleting blob: /docker/registry/v2/blobs/sha256/cc/cce6b5d4a535e729c30f1f9140a61e5fe408250c442ad69569612094970f8035" go.version=go1.11.2 instance.id=ded69299-53f9-4ffe-9309-a707264a7549 service=registry
  24. time="2019-09-20T02:53:41.577819834Z" level=info msg="Deleting blob: /docker/registry/v2/blobs/sha256/d5/d5c237920c394bda8bf1ef31b00bbde458f6978c159303e00d712a95c3f32a40" go.version=go1.11.2 instance.id=ded69299-53f9-4ffe-9309-a707264a7549 service=registry
  25. blob eligible for deletion: sha256:f17d81b4b692f7e0d6c1176c86b81d9f2cb5ac5349703adca51c61debcfe413c
  26. blob eligible for deletion: sha256:01fe0503c7f786c0613596ab151412f7fd68874d80c43289e5c32725ef1c52ff
  27. blob eligible for deletion: sha256:082bd21a11cbf8765d11f10147dc59639118b0700c43a6eef427059faa99e939
  28. blob eligible for deletion: sha256:396a68a9a5c5ed3ab7b570199a9daee6b468b5cacd4e2a6d0040e3ea7c9bb891
  29. blob eligible for deletion: sha256:3ba74338e49429d19a7e6609eee9f16faa369aa30cdcc295b5382999afa3143a
  30. blob eligible for deletion: sha256:5ed7726b81ebb228b250e4ef703ec976b56f8db47d5d9f82ce93ebb026fc6e5f
  31. time="2019-09-20T02:53:41.58367518Z" level=info msg="Deleting blob: /docker/registry/v2/blobs/sha256/f1/f17d81b4b692f7e0d6c1176c86b81d9f2cb5ac5349703adca51c61debcfe413c" go.version=go1.11.2 instance.id=ded69299-53f9-4ffe-9309-a707264a7549 service=registry
  32. time="2019-09-20T02:53:41.58874132Z" level=info msg="Deleting blob: /docker/registry/v2/blobs/sha256/01/01fe0503c7f786c0613596ab151412f7fd68874d80c43289e5c32725ef1c52ff" go.version=go1.11.2 instance.id=ded69299-53f9-4ffe-9309-a707264a7549 service=registry
  33. time="2019-09-20T02:53:41.589391384Z" level=info msg="Deleting blob: /docker/registry/v2/blobs/sha256/08/082bd21a11cbf8765d11f10147dc59639118b0700c43a6eef427059faa99e939" go.version=go1.11.2 instance.id=ded69299-53f9-4ffe-9309-a707264a7549 service=registry
  34. time="2019-09-20T02:53:41.589628015Z" level=info msg="Deleting blob: /docker/registry/v2/blobs/sha256/39/396a68a9a5c5ed3ab7b570199a9daee6b468b5cacd4e2a6d0040e3ea7c9bb891" go.version=go1.11.2 instance.id=ded69299-53f9-4ffe-9309-a707264a7549 service=registry
  35. time="2019-09-20T02:53:41.589939086Z" level=info msg="Deleting blob: /docker/registry/v2/blobs/sha256/3b/3ba74338e49429d19a7e6609eee9f16faa369aa30cdcc295b5382999afa3143a" go.version=go1.11.2 instance.id=ded69299-53f9-4ffe-9309-a707264a7549 service=registry
  36. time="2019-09-20T02:53:41.590973494Z" level=info msg="Deleting blob: /docker/registry/v2/blobs/sha256/5e/5ed7726b81ebb228b250e4ef703ec976b56f8db47d5d9f82ce93ebb026fc6e5f" go.version=go1.11.2 instance.id=ded69299-53f9-4ffe-9309-a707264a7549 service=registry
  37.   # 删除完成
    [root@localhost ~]# curl http://127.0.0.1:5000/v2/_catalog
  38. {"repositories":[]}

错误集合

a. 运行错误1

  1. 错误提示: [root@izj6c0zsm04q86s2tu4e12z /]# docker run -it docker.io/ubuntu:latest /bin/bash
  2. /usr/bin/docker-current: Error response from daemon: oci runtime error: container_linux.go:235: starting container process caused "process_linux.go:258: applying cgroup configuration for process caused \"Cannot set property TasksAccounting, or unknown property.\"".

解决办法: yum update

b. 私有仓库push错误(改配置后一定要重启docker)

  • docker私有仓库的5000端口是否在防火墙中打开

  • daemon.json文件中提交镜像的地址是否修改为私有docker仓库的地址

  • 添加镜像仓库地址insecure-registries参数,内容修改如下:

  1. vim /etc/docker/daemon.json
  2. {
  3. "registry-mirrors":["https://registry.docker-cn.com"],
  4. "insecure-registries":["47.240.32.247:5000"]
  5. }

[root@localhost bin]# systemctl daemon-reload
[root@localhost bin]# systemctl restart docker

  1.  

【linux】【docker】docker私服安装的更多相关文章

  1. linux上Docker安装gogs私服亲测(详解)

    一.前言 有网友问我为什么要使用私服,可能大部分人都不是太懂,网上那么多存储仓库而且好用方便,但是你想过没有如果企业中的项目,放在人家的仓库上这个安全性不是太好,所以说一般企业都会有自己的私服.本章教 ...

  2. 在docker容器中安装和使用,linux版的powershell

    powershell 传教士 原创文章.始于 2016-09-18 ,2016-10-27修改powershell docker官网.允许转载,但必须保留名字和出处,否则追究法律责任 1 在任意版本的 ...

  3. Linux下Docker安装

    1 在 CentOS 6.4 上安装 docker   docker当前官方只支持Ubuntu,所以在 CentOS 安装Docker比较麻烦(Issue #172).   docker官方文档说要求 ...

  4. Linux(Manjaro) - Docker - MySQL 安装配置

    Linux(Manjaro) - Docker - MySQL 安装配置 拉取mysql镜像 # 使用网易的 MySQL 镜像地址 docker pull hub.c.163.com/library/ ...

  5. linux系统docker版本升级或安装

    如果存在旧版本,则先卸载 最好先将镜像导出保存,以免升级后丢失或者无法使用 如有正在运行的容器,先停止 $ docker ps -q | xargs docker stop 关闭docker服务 $ ...

  6. Linux通过docker安装运行酷Q--用QQ骰子君进行跑团

    Linux通过docker安装运行酷Q 文:铁乐与猫 需求:和小伙伴周末进行愉快的TRPG跑团,需要在QQ讨论组上加了qq小号后,将qq小号用酷Q配合投骰的应用变成骰子君. 限制:我个人的云计算服务器 ...

  7. Windows下docker的安装,将ASP.NET Core程序部署在Linux和Docker中

    参考文章: https://www.cnblogs.com/jRoger/p/aspnet-core-deploy-to-docker.html docker for windows下载连接: htt ...

  8. oracle linux 6 docker 安装

    docker对安装系统的内核版本有严格的要求,本文针对oracle linux 6.5进行讲解,其它系统参见: https://docs.docker.com/v1.5/installation/ 下 ...

  9. Linux CentOS使用yum安装Docker

    Docker支持以下的CentOS版本: 目前,CentOS仅发行版本中的内核支持Docker. Docker运行在CentOS7上,要求系统为64位.系统内核版本为3.10以上. Docker运行在 ...

随机推荐

  1. 第一章 .NET基础-C#基础

    一.1.1. 基础语法 一.1.1.1. 注释符 一.1.1.1.1. 注释符的作用 l 注释 l 解释 一.1.1.1.2. C#中的3中注释符 l 单行注释 // l 多上注释 /* 要注释的内容 ...

  2. SpringBoot Mybatis解决使用PageHelper一对多分页问题

    一般来说使用 PageHelper 能解决绝大多数的分页问题,相关使用可在博客园上搜索,能找到很多资料. 之前我在做SpringBoot 项目时遇到这样一个问题,就是当一对多联合查询时需要分页的情况下 ...

  3. Codeforces 1006E

    #include<bits/stdc++.h> using namespace std; ; int dfn[maxn],rdfn[maxn],children[maxn]; vector ...

  4. Codeforces 976E

    题意略. 思路: 容易知道那a次倍增放在同一个怪身上是最优的,其余的怪我们只需要取hp值和damage值中间最大的那个就好了(在b值的限制下). 然而我们并不知道把那a次倍增放在哪个怪身上最好,那么我 ...

  5. Delphi - 创建text文件并添加数据到文件中

    创建文本文件 代码如下: //创建一个文本文件 procedure CreateTextFile(); var AssignFile(TF,'C:\tmp\1.txt'); ReWrite(TF); ...

  6. js封装 DOM获取

    function $(selector){ //获取第一个字符 var firstLetter = selector.charAt(0); //对第一个字符进行判断 switch(firstLette ...

  7. 转载-Spring Boot应用监控实战

    概述 之前讲过Docker容器的可视化监控,即监控容器的运行情况,包括 CPU使用率.内存占用.网络状况以及磁盘空间等等一系列信息.同样利用SpringBoot作为微服务单元的实例化技术选型时,我们不 ...

  8. 手把手教你用深度学习做物体检测(六):YOLOv2介绍

    本文接着上一篇<手把手教你用深度学习做物体检测(五):YOLOv1介绍>文章,介绍YOLOv2在v1上的改进.有些性能度量指标术语看不懂没关系,后续会有通俗易懂的关于性能度量指标的介绍文章 ...

  9. hud 1633 Orchard Trees 点是否在三角形内模板 *

    Orchard Trees Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  10. 线段树(求单结点) hdu 1556 Color the ball

    Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...