mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-03-26 03:35:31 +00:00
Add blank lines before headers
This commit is contained in:
@@ -15,6 +15,7 @@ BuildKit 引入了多项新指令,旨在优化构建缓存和安全性。以
|
||||
要使用最新的 Dockerfile 语法特性,建议在 Dockerfile 开头添加语法指令:
|
||||
|
||||
```docker
|
||||
|
||||
## syntax=docker/dockerfile:1
|
||||
|
||||
```
|
||||
@@ -53,6 +54,7 @@ COPY --from=builder /app/dist /app/dist
|
||||
`BuildKit` 提供了 `RUN --mount=type=cache` 指令,可以实现上边的设想。
|
||||
|
||||
```docker
|
||||
|
||||
## syntax=docker/dockerfile:1
|
||||
|
||||
FROM node:alpine as builder
|
||||
@@ -68,6 +70,7 @@ RUN --mount=type=cache,target=/app/node_modules,id=my_app_npm_module,sharing=loc
|
||||
COPY src /app/src
|
||||
|
||||
RUN --mount=type=cache,target=/app/node_modules,id=my_app_npm_module,sharing=locked \
|
||||
|
||||
## --mount=type=cache,target=/app/dist,id=my_app_dist,sharing=locked \
|
||||
|
||||
npm run build
|
||||
@@ -107,6 +110,7 @@ RUN --mount=type=cache,target=/tmp/dist,from=builder,source=/app/dist \
|
||||
该指令可以将一个镜像 (或上一构建阶段) 的文件挂载到指定位置。
|
||||
|
||||
```docker
|
||||
|
||||
## syntax=docker/dockerfile:1
|
||||
|
||||
RUN --mount=type=bind,from=php:alpine,source=/usr/local/bin/docker-php-entrypoint,target=/docker-php-entrypoint \
|
||||
@@ -118,6 +122,7 @@ RUN --mount=type=bind,from=php:alpine,source=/usr/local/bin/docker-php-entrypoin
|
||||
该指令可以将一个 `tmpfs` 文件系统挂载到指定位置。
|
||||
|
||||
```docker
|
||||
|
||||
## syntax=docker/dockerfile:1
|
||||
|
||||
RUN --mount=type=tmpfs,target=/temp \
|
||||
@@ -129,6 +134,7 @@ RUN --mount=type=tmpfs,target=/temp \
|
||||
该指令可以将一个文件 (例如密钥) 挂载到指定位置。
|
||||
|
||||
```docker
|
||||
|
||||
## syntax=docker/dockerfile:1
|
||||
|
||||
RUN --mount=type=secret,id=aws,target=/root/.aws/credentials \
|
||||
@@ -144,6 +150,7 @@ $ docker build -t test --secret id=aws,src=$HOME/.aws/credentials .
|
||||
该指令可以挂载 `ssh` 密钥。
|
||||
|
||||
```docker
|
||||
|
||||
## syntax=docker/dockerfile:1
|
||||
|
||||
FROM alpine
|
||||
|
||||
@@ -19,6 +19,7 @@ Buildx 使用 [BuildKit 引擎](10.1_buildkit.md)进行构建,支持许多新
|
||||
`docker buildx bake` 是一个高级构建命令,支持从 HCL、JSON 或 Compose 文件中定义构建目标,实现复杂的流水线构建。
|
||||
|
||||
```bash
|
||||
|
||||
## 从 Compose 文件构建所有服务
|
||||
|
||||
$ docker buildx bake
|
||||
|
||||
@@ -60,6 +60,7 @@ $ docker buildx inspect --bootstrap
|
||||
使用 `docker buildx build` 命令并指定 `--platform` 参数,可以同时构建支持多种架构的镜像。`--push` 参数会将构建好的镜像和 manifest list 推送到 Docker 仓库。
|
||||
|
||||
```dockerfile
|
||||
|
||||
## Dockerfile
|
||||
|
||||
FROM --platform=$TARGETPLATFORM alpine
|
||||
@@ -110,6 +111,7 @@ ENTRYPOINT ["/dist"]
|
||||
#### 创建 manifest list
|
||||
|
||||
```bash
|
||||
|
||||
## 首先,为每个架构构建并推送镜像
|
||||
|
||||
$ docker buildx build --platform linux/amd64 -t your-username/my-app:amd64 . --push
|
||||
|
||||
Reference in New Issue
Block a user