中国区使用Docker官方镜像（非国内加速）Use official Docker images in China (not domestic acceleration)
Tags: docker, vpn
Published: 2024-06-13 02:10:24

写在前面：
Foreword:
1、本文使用中英语言，英文为机翻
1、This article is written in both Chinese and English. The English version is machine-translated.
2、实测可用，完整复制命令即可使用，如有问题，请邮件至aionerljj@gmail.com 
2、The instructions have been tested and are functional. Simply copy and use the commands as they are. If you encounter any issues, please email aionerljj@gmail.com. 

正式开始：
Let's get started:
本人使用供应商提供的机场，该机场无梯子也能访问
I am using a service provided by a supplier. This service can be accessed without a VPN.

机场官方链接：{% embed  https://w1.v2free.cc/auth/register?code=oZhk %}.
Official VPN Service Link: {% embed https://w1.v2free.cc/auth/register?code=oZhk %}.
1、机场注册账号：
1、Register for a VPN Service Account:
机场页面为中文，暂未查看到英文切换选项，如需使用英文请自备翻译工具
The VPN service page is in Chinese, and there is currently no option to switch to English. Please use a translation tool if you need English.

1.1 进入链接可见以下内容：
1.1 After entering the link, you will see the following content:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xcdkm5ber380ojeuis71.png)

1.2 点击右上角注册按钮，可见以下内容
1.2 Click on the register button in the upper right corner to see the following content.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qu6oma6n1dxb4v0bj2gg.png)
**注意**：邮箱使用个人真实邮箱（不是第三方登录/注册）作为收受邮件的验证邮箱
密码自定
**Note**: Use your personal email (not a third-party login/registration) as the verification email for receiving messages.
Password can be set as desired.

1.3 注册登录成功
1.3 Successful registration and login

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xo8lnlwc4pg05wqugft5.png)
可见用户中心页面，下面进行介绍基本使用：
You will see the user center page. Below is an introduction to basic usage:
1.3.1 免费用户初始赠送1024MB流量，其他流量需登录签到，签到有时需要验证是否为真人
1.3.1 Free users initially receive 1024MB of data. Additional data can be obtained by logging in and checking in, which sometimes requires verification to confirm you are a real person.
1.3.2 免费用户注意不要找客服，可能存在封号的可能
1.3.2 Free users should avoid contacting customer service, as it may result in account suspension.
1.3.3 下方有各个系统的梯子上网使用教程
1.3.3 Below, you will find tutorials for using the VPN service on various systems.

**本人要讲的是Linux 中使用Clash**
**I will explain how to use Clash on Linux.**
根据供应商说法：Linux版访问中国网站不走代理，访问其他国家和地区的网站走代理
According to the supplier: The Linux version does not use a proxy when accessing Chinese websites, but uses a proxy for websites in other countries and regions.

2、上网前准备：
Preparation Before Going Online:
2.1 按顺序点击：Linux - Clash for linux 教程 进入该文档教程页面
2.1 Click in the following order: Linux - Clash for Linux Tutorial to enter the tutorial page.
**注意**：部分内容无法查看，请登录后再查看，因该教程提供针对每个用户的特定链接，而非共性链接
**Note**: Some content may not be viewable. Please log in to view it, as this tutorial provides specific links for each user rather than a common link.

教程页面链接：
Tutorial page link:
{% embed  https://v2free.net/doc/#/linux/clash %}.

页面部分内容截图如下：
A screenshot of part of the page content is shown below:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c1rd1qimd0muxyb2lckr.png)

请按照教程，百分百的按照其内容配置
A screenshot of part of the page content is shown below

2.2 唯有不同之处：
2.2 The only difference:
有内容如下：
There is content as follows:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4fayeuxuss6w0ikyvwrz.png)

在这里我们进行简单修改，不按照它的配置：
Here we will make a simple modification, not following its configuration:
进入你的 /root 目录，并编辑文件： .bashrc 文件，这里我使用的是vim工具
Go to your /root directory and edit the .bashrc file. I am using the vim tool for this.

```
cd /root
vim .bashrc
```
按键： 英文 I 
Press: English I
编写配置如下：
Write the following configuration:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u83sise8h2sb17265rmd.png)

完成后使配置立即生效：
After completion, make the configuration take effect immediately:

```
source .bashrc
```
使用以下命令验证是否生效：
Use the following command to verify if it is effective:

```
echo $http_proxy
echo $https_proxy
```
这里是将在命令行设置的命令，使用在全局环境中
This is a command set in the command line, used in the global environment.

2.3 完整配置完成以后，请使用命令检测：
2.3 After completing the full configuration, please use the command to check:
```
curl -I www.google.com
```
稍等一会，如显示内容如下：
Wait a moment, if the following content is displayed:
```
:~/.config/mihomo# curl -I www.google.com
HTTP/1.1 200 OK
Transfer-Encoding: chunked
......
```
即为可以访问，下面开始配置Docker的代理
It means you can access the internet. Now let's start configuring the Docker proxy.

3、Docker代理配置
3、Docker Proxy Configuration
进入目录：
Navigate to the directory:
```
cd /etc/systemd/system/ 
```
创建目录并进入：
Create a directory and enter it:
```
docker.service.d
cd docker.service.d
```
vim 创建文件编写内容：
Use vim to create a file and write the content:
```
vim http-proxy.conf

i

[Service]
Environment="HTTP_PROXY=http://127.0.0.1:7890"

shift + : 
wq

vim https-proxy.conf

i

[Service]
Environment="HTTPS_PROXY=http://127.0.0.1:7890"

shift + : 
wq
```
使用命令如下：
The commands are as follows:
```
sudo systemctl daemon-reload
sudo systemctl restart docker
```
之后命令：
Afterwards, run the command:
```
sudo systemctl show --property=Environment docker
```
确认输出包含 HTTP-PROXY和HTTPS-PROXY
Ensure the output includes HTTP-PROXY and HTTPS-PROXY.
成功后使用命令：
After successful configuration, use the command:
```
docker run busybox wget -O- http://www.google.com
```
完整正确结果如下：
The complete correct result should look like this:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mdt1sltyidys3ll4ign0.png)
注意：wget 提示can`t是正常情况无需在意
Note: If wget shows a "can't" message, it is normal and can be ignored.
至此，Docker无需国内镜像源即可访问docker 官网
At this point, Docker can access the Docker official website without using domestic mirror sources.