Docker - 访问仓库
Docker 访问 仓库
2023-09-14 09:00:40 时间
仓库与注册服务器
仓库(Repository)集中存放镜像的项目或目录。
注册服务器(Registry)管理仓库的服务器,服务器上可以有多个仓库,每个仓库有多个镜像。
例如:在仓库地址docker.io/ubuntu
中,docker.io是注册服务器地址, ubuntu是仓库名。
Docker Hub
Docker Hub是Docker官方维护的公共仓库。
网页登录Docker Hub,可以创建和删除docker用户的仓库和镜像。
Docker国内镜像的配置及使用
配置DaoCloud的Docker加速器(国内registry-mirror)
官方镜像与用户镜像
官方镜像(OFFICIAL)是基础或根镜像,由Docker公司创建、验证、支持、提供,使用单个单词作为名字,例如docker.io/centos
。
用户镜像是由Docker用户创建并维护,以用户名称作为前缀,例如docker.io/anliven/hello-world
。
自动创建
Docker Hub的自动创建(Automated Builds)功能可以跟踪GitHub等网站的项目,自动根据项目的变化执行创建。
配置自动创建之后,可以在Docker Hub的自动创建页面中跟踪每次创建的状态。
- 创建并登录 Docker Hub,以及目标网站;
- 在目标网站中连接帐户到 Docker Hub;
- 在 Docker Hub 中 配置一个自动创建;
- 选取一个目标网站中的项目( 需要含 Dockerfile) 和分支;
- 指定 Dockerfile 的位置,并提交创建。
常用命令
docker images # 查看本地镜像
docker search # 查找仓库中的镜像
docker pull # 下载仓库中的镜像到本地
docker login # 登录Docker registry
docker push # 推送镜像到Docker registry
示例:docker search 和 docker pull
[root@CentOS-7 ~]# docker images ubuntu
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/ubuntu latest 6a2f32de169d 2 weeks ago 117.2 MB
[root@CentOS-7 ~]#
[root@CentOS-7 ~]# docker search ubuntu
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/ubuntu Ubuntu is a Debian-based Linux operating s... 5919 [OK]
docker.io docker.io/rastasheep/ubuntu-sshd Dockerized SSH service, built on top of of... 81 [OK]
docker.io docker.io/ubuntu-upstart Upstart is an event-based replacement for ... 71 [OK]
docker.io docker.io/ubuntu-debootstrap debootstrap --variant=minbase --components... 30 [OK]
docker.io docker.io/torusware/speedus-ubuntu Always updated official Ubuntu docker imag... 27 [OK] [OK]
......
......
......
[root@CentOS-7 ~]#
[root@CentOS-7 ~]# docker pull ubuntu:14.04
Trying to pull repository docker.io/library/ubuntu ...
14.04: Pulling from docker.io/library/ubuntu
8f229c550c2e: Pull complete
8e1fb71e8df6: Pull complete
f75a34586856: Pull complete
8744e322b832: Pull complete
d5165bfce78f: Pull complete
Digest: sha256:edf05697d8ea17028a69726b4b450ad48da8b29884cd640fec950c904bfb50ce
[root@CentOS-7 ~]#
[root@CentOS-7 ~]# docker images ubuntu
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/ubuntu latest 6a2f32de169d 2 weeks ago 117.2 MB
docker.io/ubuntu 14.04 302fa07d8117 2 weeks ago 188 MB
[root@CentOS-7 ~]#
示例:docker login
[root@CentOS-7 ~]# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: anliven
Password:
Login Succeeded
[root@CentOS-7 ~]#
[root@CentOS-7 ~]# ls -la |grep docker
drwx------ 2 root root 24 Apr 28 10:32 .docker
[root@CentOS-7 ~]#
[root@CentOS-7 ~]# ls -la .docker # 本地用户目录的.docker中将保存相关认证信息。
total 8
drwx------ 2 root root 24 Apr 28 10:32 .
dr-xr-x---. 18 root root 4096 Apr 28 10:32 ..
-rw------- 1 root root 99 Apr 28 10:32 config.json
[root@CentOS-7 ~]#
示例:docker push
[root@CentOS-7 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/hello-world latest 48b5124b2768 3 months ago 1.84 kB
[root@CentOS-7 ~]#
[root@CentOS-7 ~]# docker tag 48b5124b2768 anliven/hello-world:test
[root@CentOS-7 ~]#
[root@CentOS-7 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
anliven/hello-world test 48b5124b2768 3 months ago 1.84 kB
docker.io/hello-world latest 48b5124b2768 3 months ago 1.84 kB
[root@CentOS-7 ~]#
[root@CentOS-7 ~]# docker push anliven/hello-world
The push refers to a repository [docker.io/anliven/hello-world]
98c944e98de8: Mounted from library/hello-world
test: digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7 size: 524
[root@CentOS-7 ~]#
[root@CentOS-7 ~]# docker search anliven/hello-world
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/anliven/hello-world 0
[root@CentOS-7 ~]#
相关文章
- Docker打包错误:Failed to execute goal com.spotify:docker-maven-plugin:1.2.0:build (default-cli) on project security
- 【docker基础知识】docker坑问题汇总
- Docker - 在Windows7中安装Docker
- Docker - 访问容器
- Docker教程---Dockerfile
- Docker 实战教程之从入门到提高 (八)
- Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
- Docker-compose 安装 zookeeper dubbo-admin
- docker从零开始(一)centos获取安装docker-ce
- 【云原生 | 44】Docker搭建Registry私有仓库之管理访问权限
- 83.第十七章 企业级容器技术docker -- Docker Compose、Docker 仓库管理(十一)
- 【问题解决】The “docker“ driver should not be used with root privileges
- 【云原生之Docker实战】使用Docker部署sapic个人图床系统
- 【云原生之Docker实战】使用docker部署webterminal堡垒机
- 【云原生之Docker实战】使用docker部署Snapdrop文件传输工具
- 【云原生之Docker实战】使用docker部署webssh工具
- docker velocyto.r
- Docker底层基石namespace与cgroup
- Docker重学系列之docker可视化工具
- Docker 部署 中间件【rabbitmq、elasticsearch】
- Docker学习笔记19:docker使用之命令大全
- Docker学习笔记14:docker使用之Machine
- Docker学习笔记13:docker使用之Compose
- a16.ansible 生产实战案例 -- docker基于镜像仓库安装harbor-https方式 playbook
- 【Docker系列】2.Linux 安装docker+docker-compose
- Docker的四种网络模型(十)
- docker 运行 Netdata