我正在使用Spotify的Docker-Client,但是遇到了文档墙。我试图弄清楚如何将已经在环境中创建的Docker机密传递给使用docker-client构建的容器。该文档仅显示了如何创建机密,但是由于机密已经存在,因此它不是很有用。我可以使用listSecrets
中的DockerClient
获取环境中的机密列表,但是无法将它们从Secret
转换为SecretBind
。非常感谢您的帮助。
答案 0 :(得分:1)
通过所有代码spotify/docker-client
代码,我发现了这一点。该文档没有显示将Secret
传递给Docker Secrets的SecretBind
转换为ContainerSpec
的方法。
public SecretBind createBind(Secret secret) {
SecretFile file = SecretFile.builder()
.name(secret.secretSpect().name())
.uid("0")
.gid("0")
.build();
SecretBind bind = SecretBind.builder()
.secretName(secret.secretSpec().name())
.secretId(secret.id())
.file(file)
.build();
return bind;
}