mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-03-26 11:45:33 +00:00
Add blank lines around headers
This commit is contained in:
@@ -110,6 +110,7 @@ RUN --mount=type=cache,target=/tmp/dist,from=builder,source=/app/dist \
|
||||
RUN --mount=type=bind,from=php:alpine,source=/usr/local/bin/docker-php-entrypoint,target=/docker-php-entrypoint \
|
||||
cat /docker-php-entrypoint
|
||||
```
|
||||
|
||||
#### `RUN --mount=type=tmpfs`
|
||||
|
||||
该指令可以将一个 `tmpfs` 文件系统挂载到指定位置。
|
||||
@@ -120,6 +121,7 @@ RUN --mount=type=bind,from=php:alpine,source=/usr/local/bin/docker-php-entrypoin
|
||||
RUN --mount=type=tmpfs,target=/temp \
|
||||
mount | grep /temp
|
||||
```
|
||||
|
||||
#### `RUN --mount=type=secret`
|
||||
|
||||
该指令可以将一个文件 (例如密钥) 挂载到指定位置。
|
||||
@@ -133,6 +135,7 @@ RUN --mount=type=secret,id=aws,target=/root/.aws/credentials \
|
||||
```bash
|
||||
$ docker build -t test --secret id=aws,src=$HOME/.aws/credentials .
|
||||
```
|
||||
|
||||
#### `RUN --mount=type=ssh`
|
||||
|
||||
该指令可以挂载 `ssh` 密钥。
|
||||
@@ -151,6 +154,7 @@ $ ssh-add ~/.ssh/id_rsa
|
||||
(Input your passphrase here)
|
||||
$ docker build -t test --ssh default=$SSH_AUTH_SOCK .
|
||||
```
|
||||
|
||||
### 10.1.2 使用 `docker compose build` 与 BuildKit
|
||||
|
||||
Docker Compose 同样支持 BuildKit,这使得多服务应用的构建更加高效。
|
||||
|
||||
@@ -26,6 +26,7 @@ $ docker buildx bake
|
||||
|
||||
$ docker buildx bake web
|
||||
```
|
||||
|
||||
#### 生成 SBOM
|
||||
|
||||
Buildx 支持在构建时直接生成 SBOM (Software Bill of Materials),这对于软件供应链安全至关重要。
|
||||
|
||||
@@ -39,6 +39,7 @@ $ docker manifest inspect hello-world
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 10.3.2 使用 `docker buildx` 构建多架构镜像
|
||||
|
||||
`docker buildx` 是构建多架构镜像的最佳实践工具,它屏蔽了底层的复杂性,提供了一键构建多架构镜像的能力。
|
||||
@@ -53,6 +54,7 @@ $ docker manifest inspect hello-world
|
||||
$ docker buildx create --name mybuilder --use
|
||||
$ docker buildx inspect --bootstrap
|
||||
```
|
||||
|
||||
#### 构建和推送
|
||||
|
||||
使用 `docker buildx build` 命令并指定 `--platform` 参数,可以同时构建支持多种架构的镜像。`--push` 参数会将构建好的镜像和 manifest list 推送到 Docker 仓库。
|
||||
@@ -96,6 +98,7 @@ COPY bin/dist-${TARGETOS}-${TARGETARCH} /dist
|
||||
|
||||
ENTRYPOINT ["/dist"]
|
||||
```
|
||||
|
||||
### 10.3.3 使用 `docker manifest`:底层工具
|
||||
|
||||
除了 `docker buildx`,我们也可以直接操作 Manifest List 来手动组合不同架构的镜像。
|
||||
@@ -120,6 +123,7 @@ $ docker manifest create your-username/my-app:latest \
|
||||
|
||||
$ docker manifest push your-username/my-app:latest
|
||||
```
|
||||
|
||||
#### 检查 manifest list
|
||||
|
||||
你可以使用 `docker manifest inspect` 来查看一个 manifest list 的详细信息,如上文所示。
|
||||
|
||||
Reference in New Issue
Block a user