运维之道 | Docker 仓库管理

Docker 仓库管理

仓库(Repository)是集中存放镜像的地方。以下介绍一下 Docker Hub。当然不止 docker hub,只是远程的服务商不一样,操作都是一样的。


Docker Hub

目前 Docker 官方维护了一个公共仓库 dDocker Hub。
大部分需求都可以通过在 Docker Hub 中直接下载镜像来实现。


注册

Docker Hub免费注册一个 Docker 账号
在这里插入图片描述


登录、退出、使用

登录需要输入用户名和密码,登录成功后,我们就可以从 docker hub 上拉取自己账号下的全部镜像。

  • 登录
[root@localhost ~]#: 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: 270330615
Password: 
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@localhost ~]#: docker logout
Removing login credentials for https://index.docker.io/v1/
  • 拉取镜像
    你可以通过 docker search 命令来查找官方仓库中的镜像,并利用 docker pull 命令来将它下载到本地。
    以 ubuntu 为关键词进行搜索:
[root@localhost ~]#: docker search ubuntu
NAME                                                      DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
ubuntu                                                    Ubuntu is a Debian-based Linux operating sys…   10167               [OK]                
dorowu/ubuntu-desktop-lxde-vnc                            Docker image to provide HTML5 VNC interface362                                     [OK]
rastasheep/ubuntu-sshd                                    Dockerized SSH service, built on top of offi…   235                                     [OK]
  • 镜像下载
    使用 docker pull 将官方 ubuntu 镜像下载到本地:
[root@localhost ~]#: docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
Digest: sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d
Status: Image is up to date for ubuntu:latest
docker.io/library/ubuntu:latest
  • 推送镜像
    用户登录后,可以通过 docker push 命令将自己的镜像推送到 Docker Hub。
    以下命令中的 username 请替换为你的 Docker 账号用户名。
[root@localhost ~]#: docker tag ubuntu 270330615/ubuntu
[root@localhost ~]#: docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
270330615/ubuntu    latest              775349758637        2 weeks ago         64.2MB

[root@localhost ~]#:  docker push username/ubuntu:18.04
[root@localhost ~]#:  docker search username/ubuntu

NAME             DESCRIPTION       STARS         OFFICIAL    AUTOMATED
username/ubuntu


转载至:https://www.runoob.com/docker/docker-repository.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值