# docker远程仓库

类比于Git将代码托管至Github远程仓库, Docker Hub是docker将image托管的公共远程镜像仓库. 可以将自己的私有image上传托管到Docker Hub, 也可以如同Github clone 代码仓库一样, 将公共的image pull到本地使用.

## 注册

首先需要在[Docker Hub](https://hub.docker.com/)注册个人账号.

## 登录

在本地使用docker命令从Docker Hub中进行pull和push操作, 首先需要登录.

### Windows & MacOS

Windows & MacOS 都使用Docker Desktop图形化界面应用启动docker服务, 界面中都有登录按钮. 点击后使用用户名/密码登录即可. 然后就可以在命令行中对私有仓库进行push/pull操作.

需要注意的是, 对远程公共镜像进行pull时, 是不需要登录的.

### Linux

使用`docker login`命令进行登录.

```bash
docker login [OPTIONS] [SERVER]
```

`OPTIONS`中有两个比较重要的参数:

* `-u`: 帐号
* `-p`: 密码

不使用这两个参数, 单纯使用`docker login`, 会通过命令号交互的方式依次提示输入帐号和密码进行登录.

`SERVER`如果不指定, 默认是连接Docker Hub. 一般公司都会维护自己的docker托管仓库, 使用这些仓库, 在登录时需要指定SERVER地址.

参考:

* [docker login 命令详解](https://www.cnblogs.com/poloyy/p/13948922.html)
* [docker login 登录非 docker hub 仓库](https://blog.csdn.net/benben_2015/article/details/83446408)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kerasnoone.gitbook.io/garnet/gong-cheng-zhan/docker-ge-li-yuan-li/docker-yuan-cheng-cang-ku.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
