使用 Buildx 构建镜像
启用 Buildx
要在Docker CLI中启用实验性功能,需要编辑config.json
文件,并将experimental
设置为enabled
$ mkdir ~/.docker
$ cat > ~/.docker/config.json <<EOF
{
"experimental": "enabled"
}
EOF
验证方式,查看Experimental 为true
[root@node .docker]$ docker version
Client: Docker Engine - Community
Version: 19.03.9
API version: 1.40
Go version: go1.13.10
Git commit: 9d988398e7
Built: Fri May 15 00:25:27 2020
OS/Arch: linux/amd64
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 19.03.9
API version: 1.40 (minimum version 1.12)
Go version: go1.13.10
Git commit: 9d988398e7
Built: Fri May 15 00:24:05 2020
OS/Arch: linux/amd64
Experimental: true
containerd:
Version: 1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
使用
你可以直接使用 docker buildx build
命令构建镜像。
$ docker buildx build .
[+] Building 8.4s (23/32)
=> ...
Buildx 使用 BuildKit 引擎 进行构建,支持许多新的功能,具体参考 Buildkit 一节。