27 Commits

Author SHA1 Message Date
Kang Huaishuai
57873b1143 Merge pull request #523 from wushu037/patch-1
Update volume.md
2023-05-15 08:58:42 +08:00
无数
6acf209b9a Update volume.md
Correct confusing words
2023-05-07 21:34:34 +08:00
Kang Huaishuai
ed4b3efd3b Merge pull request #520 from ReginaldChen/patch-1
修改错别字
2023-02-27 08:10:33 +08:00
ReginaldChen
eb327bf908 修改错别字
轮寻应为轮询
2023-02-24 17:41:22 +08:00
Baohua Yang
cc683fdb56 Merge pull request #519 from docete/issue-518
Add docs of using HTTP/HTTPS proxy

Close #518
2023-01-17 12:03:57 -08:00
Gao Zhenghua
13b8e12f44 [issue-518] Add document on how to use HTTP/HTTPS proxy 2023-01-16 16:13:20 +08:00
Kang Huaishuai
ce4428adfb Merge pull request #517 from hezhizhen/patch-1
fix: typo
2023-01-08 20:04:47 +08:00
Zhizhen He
6443ddc07c fix: typo 2023-01-07 23:45:41 +08:00
Kang Huaishuai
ce5ae6a360 Merge pull request #515 from kingyue737/patch-1
fix: typo
2022-12-22 15:39:38 +08:00
Kang Huaishuai
35b264694b Merge pull request #516 from kingyue737/patch-2
fix: wrong key of registry mirrors
2022-12-22 15:39:14 +08:00
Yue JIN
e76b0b66a0 fix: wrong key of registry mirrors 2022-12-21 20:32:46 +08:00
Yue JIN
d80f3430b2 fix: typo 2022-12-21 19:38:21 +08:00
Baohua Yang
d9c5d2fb43 Merge pull request #514 from Hazel-Lin/install/mac
Update macos requirement in doc
2022-11-11 18:15:38 -08:00
linhuizi
fe7530c3f6 docs(install): 修改Mac安装系统要求 2022-11-11 11:31:02 +08:00
Baohua Yang
30f00323e0 Merge pull request #512 from WitchElaina/master
fix words
2022-10-22 11:29:13 -07:00
WitchElaina
93ea51ff07 修改语病
原句:“这也是为什么有人认为 Go 是特别适合容器微服务架构的语言的原因之一”中的“为什么”和“的原因”重复赘余,因此删除掉“为什么”确保本句语法正确。
2022-10-22 15:42:59 +08:00
Baohua Yang
85be3008fa Update words
Fix #501
2022-05-12 14:37:08 -07:00
Baohua Yang
88f9183fd5 Merge pull request #500 from mrnyg/patch-1
Enable non-root read mod
2022-04-11 10:06:43 -07:00
mrnyg
1c4a43e34e Update secret.md
apache工作进程是www-data用户运行,而密钥文件(/run/secrets/wp_db_password)的属主是root,导致apache工作进程无法读取密钥,从而无法连接数据库
2022-04-09 14:27:53 +08:00
Baohua Yang
7014e4d87c Create FUNDING.yml 2022-03-16 15:14:06 -07:00
Kang Huaishuai
18028b8eaa Update dockerhub autobuild
Signed-off-by: Kang Huaishuai <khs1994@khs1994.com>
2022-02-24 21:08:22 +08:00
Kang Huaishuai
7c78d1c256 centos refer to centos:8, deprecated
Signed-off-by: Kang Huaishuai <khs1994@khs1994.com>
2022-02-24 21:06:15 +08:00
Baohua Yang
d4c6e590c6 Merge pull request #497 from npmmirror/master
Update https://registry.npm.taobao.org to https://registry.npmmirror.com
2022-02-16 11:50:56 -08:00
NPM Mirror Bot
1e415ac76c update https://registry.npm.taobao.org to https://registry.npmmirror.com 2022-02-11 22:09:47 -05:00
NPM Mirror Bot
664ac88c85 update https://registry.npm.taobao.org to https://registry.npmmirror.com 2022-02-11 13:56:55 +00:00
Kang Huaishuai
734079661d Merge pull request #496 from smartlixx/patch-1
Update best_practices.md
2022-01-04 11:01:18 +08:00
Xianxiang Li
1ed8c2c81f Update best_practices.md
Fix a typo
2022-01-04 10:41:51 +08:00
16 changed files with 107 additions and 19 deletions

13
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,13 @@
# These are supported funding model platforms
github: yeasy
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

View File

@@ -75,6 +75,7 @@
* [自定义网桥](advanced_network/bridge.md) * [自定义网桥](advanced_network/bridge.md)
* [工具和示例](advanced_network/example.md) * [工具和示例](advanced_network/example.md)
* [编辑网络配置文件](advanced_network/config_file.md) * [编辑网络配置文件](advanced_network/config_file.md)
* [配置 HTTP/HTTPS 网络代理](advanced_network/http_https_proxy.md)
* [实例创建一个点到点连接](advanced_network/ptp.md) * [实例创建一个点到点连接](advanced_network/ptp.md)
* [Docker Buildx](buildx/README.md) * [Docker Buildx](buildx/README.md)
* [BuildKit](buildx/buildkit.md) * [BuildKit](buildx/buildkit.md)

View File

@@ -0,0 +1,74 @@
# 配置 HTTP/HTTPS 网络代理
使用Docker的过程中因为网络原因通常需要使用 HTTP/HTTPS 代理来加速镜像拉取构建和使用下面是常见的三种场景
## dockerd 设置网络代理
"docker pull" 命令是由 dockerd 守护进程执行 dockerd 守护进程是由 systemd 管理因此如果需要在执行 "docker pull" 命令时使用 HTTP/HTTPS 代理需要通过 systemd 配置
- dockerd 创建配置文件夹
```
sudo mkdir -p /etc/systemd/system/docker.service.d
```
- dockerd 创建 HTTP/HTTPS 网络代理的配置文件文件路径是 /etc/systemd/system/docker.service.d/http-proxy.conf 并在该文件中添加相关环境变量
```
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:8080/"
Environment="HTTPS_PROXY=http://proxy.example.com:8080/"
Environment="NO_PROXY=localhost,127.0.0.1,.example.com"
```
- 刷新配置并重启 docker 服务
```
sudo systemctl daemon-reload
sudo systemctl restart docker
```
## docker 容器设置网络代理
在容器运行阶段如果需要使用 HTTP/HTTPS 代理可以通过更改 docker 客户端配置或者指定环境变量的方式
- 更改 docker 客户端配置创建或更改 ~/.docker/config.json并在该文件中添加相关配置
```
{
"proxies":
{
"default":
{
"httpProxy": "http://proxy.example.com:8080/",
"httpsProxy": "http://proxy.example.com:8080/",
"noProxy": "localhost,127.0.0.1,.example.com"
}
}
}
```
- 指定环境变量运行 "docker run" 命令时指定相关环境变量
| 环境变量 | docker run 示例 |
| -------- | ---------------- |
| HTTP_PROXY | --env HTTP_PROXY="http://proxy.example.com:8080/" |
| HTTPS_PROXY | --env HTTPS_PROXY="http://proxy.example.com:8080/" |
| NO_PROXY | --env NO_PROXY="localhost,127.0.0.1,.example.com" |
## docker build 过程设置网络代理
在容器构建阶段如果需要使用 HTTP/HTTPS 代理可以通过指定 "docker build" 的环境变量或者在 Dockerfile 中指定环境变量的方式
- 使用 "--build-arg" 指定 "docker build" 的相关环境变量
```
docker build \
--build-arg "HTTP_PROXY=http://proxy.example.com:8080/" \
--build-arg "HTTPS_PROXY=http://proxy.example.com:8080/" \
--build-arg "NO_PROXY=localhost,127.0.0.1,.example.com" .
```
- Dockerfile 中指定相关环境变量
| 环境变量 | Dockerfile 示例 |
| -------- | ---------------- |
| HTTP_PROXY | ENV HTTP_PROXY="http://proxy.example.com:8080/" |
| HTTPS_PROXY | ENV HTTPS_PROXY="http://proxy.example.com:8080/" |
| NO_PROXY | ENV NO_PROXY="localhost,127.0.0.1,.example.com" |

View File

@@ -167,9 +167,9 @@ RUN apt-get update && apt-get install -y \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
``` ```
其中 `s3cmd` 指令指定了一个版本号 `1.1.*`如果之前的镜像使用的是更旧的版本指定新的版本会导致 `apt-get udpate` 缓存失效并确保安装的是新版本 其中 `s3cmd` 指令指定了一个版本号 `1.1.*`如果之前的镜像使用的是更旧的版本指定新的版本会导致 `apt-get update` 缓存失效并确保安装的是新版本
另外清理掉 apt 缓存 `var/lib/apt/lists` 可以减小镜像大小因为 `RUN` 指令的开头为 `apt-get udpate`包缓存总是会在 `apt-get install` 之前刷新 另外清理掉 apt 缓存 `var/lib/apt/lists` 可以减小镜像大小因为 `RUN` 指令的开头为 `apt-get update`包缓存总是会在 `apt-get install` 之前刷新
> 注意官方的 Debian Ubuntu 镜像会自动运行 apt-get clean所以不需要显式的调用 apt-get clean > 注意官方的 Debian Ubuntu 镜像会自动运行 apt-get clean所以不需要显式的调用 apt-get clean
@@ -329,7 +329,7 @@ $ docker run --rm -it postgres bash
如果某个服务不需要特权执行建议使用 `USER` 指令切换到非 root 用户先在 `Dockerfile` 中使用类似 `RUN groupadd -r postgres && useradd -r -g postgres postgres` 的指令创建用户和用户组 如果某个服务不需要特权执行建议使用 `USER` 指令切换到非 root 用户先在 `Dockerfile` 中使用类似 `RUN groupadd -r postgres && useradd -r -g postgres postgres` 的指令创建用户和用户组
>注意在镜像中用户和用户组每次被分配的 UID/GID 都是不确定的下次重新构建镜像时被分配到的 UID/GID 可能会不一样如果要依赖确定的 UID/GID你应该显的指定一个 UID/GID >注意在镜像中用户和用户组每次被分配的 UID/GID 都是不确定的下次重新构建镜像时被分配到的 UID/GID 可能会不一样如果要依赖确定的 UID/GID你应该显的指定一个 UID/GID
你应该避免使用 `sudo`因为它不可预期的 TTY 和信号转发行为可能造成的问题比它能解决的问题还多如果你真的需要和 `sudo` 类似的功能例如 root 权限初始化某个守护进程以非 root 权限执行它你可以使用 [gosu](https://github.com/tianon/gosu)。 你应该避免使用 `sudo`因为它不可预期的 TTY 和信号转发行为可能造成的问题比它能解决的问题还多如果你真的需要和 `sudo` 类似的功能例如 root 权限初始化某个守护进程以非 root 权限执行它你可以使用 [gosu](https://github.com/tianon/gosu)。

View File

@@ -10,17 +10,17 @@ CentOSCommunity Enterprise Operating System中文意思是社区企业
### 使用 CentOS 官方镜像 ### 使用 CentOS 官方镜像
使用 `docker run` 直接运行最新的 `CentOS` 镜像并登录 `bash` 使用 `docker run` 直接运行 `CentOS 7` 镜像并登录 `bash`
```bash ```bash
$ docker run -it centos bash $ docker run -it centos:7 bash
Unable to find image 'centos:latest' locally Unable to find image 'centos:latest' locally
latest: Pulling from library/centos latest: Pulling from library/centos
3d8673bd162a: Pull complete 3d8673bd162a: Pull complete
Digest: sha256:a66ffcb73930584413de83311ca11a4cb4938c9b2521d331026dad970c19adf4 Digest: sha256:a66ffcb73930584413de83311ca11a4cb4938c9b2521d331026dad970c19adf4
Status: Downloaded newer image for centos:latest Status: Downloaded newer image for centos:latest
[root@43eb3b194d48 /]# cat /etc/redhat-release [root@43eb3b194d48 /]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core) CentOS Linux release 7.9.2009 (Core)
``` ```
## Fedora 系统简介 ## Fedora 系统简介

View File

@@ -1,6 +1,6 @@
# 数据卷 # 数据卷
`数据卷` 是一个可供一个或多个容器使用的特殊目录它绕过 UFS可以提供很多有用的特性 `数据卷` 是一个可供一个或多个容器使用的特殊目录它绕过 UnionFS可以提供很多有用的特性
* `数据卷` 可以在容器之间共享和重用 * `数据卷` 可以在容器之间共享和重用

View File

@@ -40,7 +40,7 @@ FROM scratch
如果你以 `scratch` 为基础镜像的话意味着你不以任何镜像为基础接下来所写的指令将作为镜像第一层开始存在 如果你以 `scratch` 为基础镜像的话意味着你不以任何镜像为基础接下来所写的指令将作为镜像第一层开始存在
不以任何系统为基础直接将可执行文件复制进镜像的做法并不罕见对于 Linux 下静态编译的程序来说并不需要有操作系统提供运行时支持所需的一切库都已经在可执行文件里了因此直接 `FROM scratch` 会让镜像体积更加小巧使用 [Go 语言](https://golang.google.cn/) 开发的应用很多会使用这种方式来制作镜像,这也是为什么有人认为 Go 是特别适合容器微服务架构的语言的原因之一。 不以任何系统为基础直接将可执行文件复制进镜像的做法并不罕见对于 Linux 下静态编译的程序来说并不需要有操作系统提供运行时支持所需的一切库都已经在可执行文件里了因此直接 `FROM scratch` 会让镜像体积更加小巧使用 [Go 语言](https://golang.google.cn/) 开发的应用很多会使用这种方式来制作镜像,这也是有人认为 Go 是特别适合容器微服务架构的语言的原因之一。
## RUN 执行命令 ## RUN 执行命令

View File

@@ -4,7 +4,7 @@ WORKDIR /app
COPY package.json /app/ COPY package.json /app/
RUN npm i --registry=https://registry.npm.taobao.org \ RUN npm i --registry=https://registry.npmmirror.com \
&& rm -rf ~/.npm && rm -rf ~/.npm
COPY src /app/src COPY src /app/src

View File

@@ -8,7 +8,7 @@ COPY package.json /app/
RUN --mount=type=cache,target=/app/node_modules,id=my_app_npm_module,sharing=locked \ RUN --mount=type=cache,target=/app/node_modules,id=my_app_npm_module,sharing=locked \
--mount=type=cache,target=/root/.npm,id=npm_cache \ --mount=type=cache,target=/root/.npm,id=npm_cache \
npm i --registry=https://registry.npm.taobao.org npm i --registry=https://registry.npmmirror.com
COPY src /app/src COPY src /app/src

View File

@@ -1,6 +1,6 @@
# 参考文档 # 参考文档
* `Dockerfie` 官方文档https://docs.docker.com/engine/reference/builder/ * `Dockerfile` 官方文档https://docs.docker.com/engine/reference/builder/
* `Dockerfile` 最佳实践文档https://docs.docker.com/develop/develop-images/dockerfile_best-practices/ * `Dockerfile` 最佳实践文档https://docs.docker.com/develop/develop-images/dockerfile_best-practices/

View File

@@ -61,7 +61,7 @@ FROM node:alpine as frontend
COPY package.json /app/ COPY package.json /app/
RUN set -x ; cd /app \ RUN set -x ; cd /app \
&& npm install --registry=https://registry.npm.taobao.org && npm install --registry=https://registry.npmmirror.com
COPY webpack.mix.js webpack.config.js tailwind.config.js /app/ COPY webpack.mix.js webpack.config.js tailwind.config.js /app/
COPY resources/ /app/resources/ COPY resources/ /app/resources/
@@ -179,7 +179,7 @@ FROM node:alpine as frontend
COPY package.json /app/ COPY package.json /app/
RUN set -x ; cd /app \ RUN set -x ; cd /app \
&& npm install --registry=https://registry.npm.taobao.org && npm install --registry=https://registry.npmmirror.com
COPY webpack.mix.js webpack.config.js tailwind.config.js /app/ COPY webpack.mix.js webpack.config.js tailwind.config.js /app/
COPY resources/ /app/resources/ COPY resources/ /app/resources/

View File

@@ -2,7 +2,7 @@
## 系统要求 ## 系统要求
[Docker Desktop for Mac](https://docs.docker.com/docker-for-mac/) 要求系统最低为 macOS Mojave 10.14 [Docker Desktop for Mac](https://docs.docker.com/docker-for-mac/) 要求系统最低为 macOS 必须是 10.15 或更高版本, Catalina、Big Sur 或者 Monterey建议升级到最新版本的 macOS
## 安装 ## 安装

View File

@@ -62,7 +62,7 @@ Kubernetes 校验节点可用依赖于 ID。在当前的版本中有两个接
* 集群范围内节点同步 * 集群范围内节点同步
* 单节点生命周期管理 * 单节点生命周期管理
节点控制有一个同步轮主要监听所有云平台的虚拟实例会根据节点状态创建和删除可以通过 `--node_sync_period`标志来控制该轮如果一个实例已经创建节点控制将会为其创建一个结构同样的如果一个节点被删除节点控制也会删除该结构 Kubernetes 启动时可用通过 `--machines`标记来显示指定节点同样可以使用 `kubectl` 来一条一条的添加节点两者是相同的通过设置 `--sync_nodes=false`标记来禁止集群之间的节点同步你也可以使用 api/kubectl 命令行来增删节点 节点控制有一个同步轮主要监听所有云平台的虚拟实例会根据节点状态创建和删除可以通过 `--node_sync_period`标志来控制该轮如果一个实例已经创建节点控制将会为其创建一个结构同样的如果一个节点被删除节点控制也会删除该结构 Kubernetes 启动时可用通过 `--machines`标记来显示指定节点同样可以使用 `kubectl` 来一条一条的添加节点两者是相同的通过设置 `--sync_nodes=false`标记来禁止集群之间的节点同步你也可以使用 api/kubectl 命令行来增删节点
## 容器组 ## 容器组

View File

@@ -75,9 +75,9 @@ username/ubuntu
## 自动构建 ## 自动构建
> 2021 6 18 日之后该项功能仅限[付费用户](https://www.docker.com/blog/changes-to-docker-hub-autobuilds/)使用。 > 2021 7 26 日之后该项功能仅限[付费用户](https://www.docker.com/blog/changes-to-docker-hub-autobuilds/)使用。
自动构建`Automated Builds`功能对于需要经常升级镜像内程序来说十分方便 自动构建`Automated Builds`可以自动触发构建镜像方便升级镜像
有时候用户构建了镜像安装了某个软件当软件发布新版本则需要手动更新镜像 有时候用户构建了镜像安装了某个软件当软件发布新版本则需要手动更新镜像

View File

@@ -103,7 +103,7 @@ REPOSITORY TAG IMAGE ID CREAT
```json ```json
{ {
"registry-mirror": [ "registry-mirrors": [
"https://hub-mirror.c.163.com", "https://hub-mirror.c.163.com",
"https://mirror.baidubce.com" "https://mirror.baidubce.com"
], ],

View File

@@ -62,7 +62,7 @@ $ docker service create \
--network mysql_private \ --network mysql_private \
--publish target=30000,port=80 \ --publish target=30000,port=80 \
--mount type=volume,source=wpdata,destination=/var/www/html \ --mount type=volume,source=wpdata,destination=/var/www/html \
--secret source=mysql_password,target=wp_db_password,mode=0400 \ --secret source=mysql_password,target=wp_db_password,mode=0444 \
-e WORDPRESS_DB_USER="wordpress" \ -e WORDPRESS_DB_USER="wordpress" \
-e WORDPRESS_DB_PASSWORD_FILE="/run/secrets/wp_db_password" \ -e WORDPRESS_DB_PASSWORD_FILE="/run/secrets/wp_db_password" \
-e WORDPRESS_DB_HOST="mysql:3306" \ -e WORDPRESS_DB_HOST="mysql:3306" \