Skip to main content

docker buildx bake

cat << EOF > Dockerfile
FROM wener/base
RUN touch test
EOF
cat << HCL > docker-bake.hcl
target "default" {
dockerfile = "Dockerfile"
platforms = ["linux/amd64", "linux/arm64"]
pull = true
}
HCL

# moby/buildkit:buildx-stable-1
docker context create --use

docker buildx bake
varfor
BAKE_CMD_CONTEXT
BAKE_LOCAL_PLATFORM当前平台 linux/amd64

使用环境变量作为默认

variable "HOME" {
default = "$HOME"
}

target "default" {
ssh = ["default=${HOME}/.ssh/id_rsa"]
}