我正在使用构建秘密提供诗歌认证,但它没有被安装到环境中,我从docker 文档中复制并修改了示例。
export DOCKER_BUILDKIT=1
docker build \
--secret id=poetry_johndoe_auth_username,env=POETRY_HTTP_BASIC_JOHNDOE_GITLAB_USERNAME \
--secret id=poetry_johndoe_auth_password,env=POETRY_HTTP_BASIC_JOHNDOE_GITLAB_PASSWORD \
-t example:latest .
在dockerfile中我正在安装到环境中
RUN --mount=type=secret,id=poetry_johndoe_auth_username,env=POETRY_HTTP_BASIC_JOHNDOE_GITLAB_USERNAME \
--mount=type=secret,id=poetry_johndoe_auth_password,env=POETRY_HTTP_BASIC_JOHNDOE_GITLAB_PASSWORD \
pip install -r /tmp/requirements.txt
CI 返回以下错误
Dockerfile:17
--------------------
16 |
17 | >>> RUN --mount=type=secret,id=poetry_johndoe_auth_username,env=POETRY_HTTP_BASIC_JOHNDOE_GITLAB_USERNAME \
18 | >>> --mount=type=secret,id=poetry_johndoe_auth_password,env=POETRY_HTTP_BASIC_JOHNDOE_GITLAB_PASSWORD \
19 | >>> pip install -r /tmp/requirements.txt
20 |
--------------------
ERROR: failed to solve: unexpected key 'env' in 'env=POETRY_HTTP_BASIC_JOHNDOE_GITLAB_USERNAME'
Dockerfile
RUN --mount=type=secret
不支持 Dockerfiles 中的 env 选项。您必须读取运行命令的秘密并通过 将其分配给 docker ENV
export
。你的
DOCKER RUN
命令看起来应该像这样:如果您要求他们在
.bashrc
,您可以:由于所有机密都以文件形式存储,因此只需读取并导出即可。例如