gpt4 book ai didi

docker - 如何将配置文件推送到新的 oryd/hydra docker 镜像?

转载 作者:IT王子 更新时间:2023-10-29 02:06:32 25 4
gpt4 key购买 nike

我正在使用 oryd/hydra docker 镜像:https://hub.docker.com/r/oryd/hydra为了使用我自己的配置构建自定义图像。

我确实创建了一个自定义目录:

mkdir sso-demo-hydra
cd sso-demo-hydra

然后我使用该语法创建一个 Dockerfile:

vi Dockerfile

文件内容:

$ cat Dockerfile

FROM oryd/hydra:latest

COPY .hydra /

构建图像时没有出现错误:

$ docker build -t sso-demo-hydra .

Sending build context to Docker daemon 8.704kB

Step 1/2 : FROM oryd/hydra:latest

---> 50f0a70dbda9

Step 2/2 : COPY .hydra /

---> Using cache

---> 3539634979c0

Successfully built 3539634979c0

Successfully tagged sso-demo-hydra:latest

SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.

当我启动应用程序时,我收到以下警告:

sso-demo-hydra | Config file not found because "Config File ".hydra" Not Found in "[/]""

PS:context目录下有一个.hydra文件

感谢您的支持。

最佳答案

参见 github source code此docker镜像的相关代码如下:

func initConfig() {
if cfgFile != "" {
// enable ability to specify config file via flag
viper.SetConfigFile(cfgFile)
} else {
path := absPathify("$HOME")
if _, err := os.Stat(filepath.Join(path, ".hydra.yml")); err != nil {
_, _ = os.Create(filepath.Join(path, ".hydra.yml"))
}

viper.SetConfigType("yaml")
viper.SetConfigName(".hydra") // name of config file (without extension)
viper.AddConfigPath("$HOME") // adding home directory as first search path
}

viper.SetDefault("LOG_LEVEL", "info")

viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.AutomaticEnv() // read in environment variables that match

// If a config file is found, read it in.
if err := viper.ReadInConfig(); err != nil {
fmt.Printf(`Config file not found because "%s"`, err)
fmt.Println("")
}
}

从上面,你可以看到实际上它期望的是.hydra.yml,而不是.hydra.hydra只是一个删除扩展名:

viper.SetConfigName(".hydra") // name of config file (without extension)

所以根本原因是:它的错误指示不友好,让你遇到问题,改用.hydra.yml就可以了。

关于docker - 如何将配置文件推送到新的 oryd/hydra docker 镜像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57559268/

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