gpt4 book ai didi

docker - 在 Docker 中使用构建时参数的安全方法

转载 作者:行者123 更新时间:2023-12-04 16:42:23 25 4
gpt4 key购买 nike

我有一个构建时间参数,我想用它来构建我的 Docker 文件;由于该论点本质上是 secret 的(私有(private) repo 的 github key ),我不希望它最终出现在 docker 镜像中。此引用来自有关构建时参数的官方 docker 文档。

Warning: It is not recommended to use build-time variables for passing secrets like github keys, user credentials etc. Build-time variable values are visible to any user of the image with the docker history command.



有人知道实现相同目标的推荐方法是什么吗?

最佳答案

使用 docker 18.09+,这将是: docker build --secret id=mysecret,src=/secret/file (使用 buildkit )。

PR 1288 , 宣布 in this tweet .--secret现在由 API version 1.39 看守.

例子:

printf "hello secret" > ./mysecret.txt

export DOCKER_BUILDKIT=1

docker build --no-cache --progress=plain --secret id=mysecret,src=$(pwd)/mysecret.txt -f - . <<EOF
# syntax = tonistiigi/dockerfile:secrets20180808
FROM busybox
RUN --mount=type=secret,id=mysecret cat /run/secrets/mysecret
RUN --mount=type=secret,id=mysecret,dst=/foobar cat /foobar
EOF

关于docker - 在 Docker 中使用构建时参数的安全方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45405212/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com