Answer the question
In order to leave comments, you need to log in
Why does not see the config file in Docker?
Hi, using viper I take data from the config. Locally everything works fine, but when I run it in docker it can't find it.
Error: Config File \"local\" Not Found in \"[/configs]\"
Dockerfile:
FROM registry.gitlab.com/gitlab-org/gitlab-build-images:golangci-lint-alpine as builder
WORKDIR /build
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -o auth ./cmd/main.go
# generate clean, final image for end users
FROM quay.io/jitesoft/alpine:3.11.3
COPY --from=builder /build/auth /chupapimunyanya/
COPY --from=builder /build/configs /chupapimunyanya/configs/
COPY --from=builder /build/db /chupapimunyanya/db/
# executable
ENTRYPOINT [ "/chupapimunyanya/app/auth" ]
viper.AddConfigPath("configs")
viper.SetConfigName("local")
auth/
--cmd/
----main.go
--configs/
----local.yml
Answer the question
In order to leave comments, you need to log in
Not strong in Go, but /configs is obviously the path from the root, but in fact the path is /chupapimunyanya/configs/
Go into the container ( docker exec -it имя_контейнера sh
) and check if the files are placed correctly.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question