仓库(Repository):集中存放镜像的地方,分为公共仓库和私有仓库; 注册服务器(Registry):存放仓库的具体服务器,一个注册服务器可以有多个仓库; 官方公共仓库 Docker Hub 地址:[https://hub.docker.com/](https://hub.docker.com/);

Docker Hub 公共镜像市场

登录 - docker login

  1. PS C:\Users\1314y> docker login -u 1314yjh
  2. Password:
  3. Login Succeeded

退出 - docker logout

  1. PS C:\Users\1314y> docker logout
  2. Removing login credentials for https://index.docker.io/v1/
  3. PS C:\Users\1314y>

搭建本地私有仓库

需要注意: “insecure-registries”: [ “192.168.1.237:5000” ],

使用 registry 镜像创建私有仓库

我测试用的 window 10 操作系统。ip 为:192.168.1.237。

  1. # 创建私有仓库
  2. PS C:\Users\1314y> docker run -d -p 5000:5000 registry:2
  3. Unable to find image 'registry:2' locally
  4. 2: Pulling from library/registry
  5. 6a428f9f83b0: Already exists
  6. 90cad49de35d: Pull complete
  7. b215d0b40846: Pull complete
  8. 429305b6c15c: Pull complete
  9. 6f7e10a4e907: Pull complete
  10. Digest: sha256:265d4a5ed8bf0df27d1107edb00b70e658ee9aa5acb3f37336c5a17db634481e
  11. Status: Downloaded newer image for registry:2
  12. 7471723b188525f9a2f44df09749aa10fa6aaa6b16e0a3a40394025289a6a5fe
  13. PS C:\Users\1314y> docker ps
  14. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  15. 7471723b1885 registry:2 "/entrypoint.sh /etc…" 9 seconds ago Up 8 seconds 0.0.0.0:5000->5000/tcp, :::5000->5000/tcp xenodochial_brattain
  16. # 准备镜像
  17. PS C:\Users\1314y> docker tag ubuntu:latest 192.168.1.237:5000/test_ubuntu:1.0.0.1
  18. PS C:\Users\1314y> docker images
  19. 192.168.1.237:5000/test_ubuntu 1.0.0.1 597ce1600cf4 11 days ago 72.8MB
  20. ubuntu latest 597ce1600cf4 11 days ago 72.8MB
  21. # 上传镜像
  22. PS C:\Users\1314y> docker push 192.168.1.237:5000/test_ubuntu:1.0.0.1
  23. # 下载
  24. PS C:\Users\1314y> docker pull 192.168.1.237:5000/test_ubuntu:1.0.0.1