This commit is contained in:
qiaofeng1227 2024-12-06 16:11:04 +08:00
parent 2f7e4bf546
commit 0220641c0c
2 changed files with 7 additions and 4 deletions

View File

@ -13,7 +13,7 @@ RUN chmod +x /init_portainer
# Dockerfile refer to: https://github.com/portainer/portainer/blob/develop/build/linux/Dockerfile # Dockerfile refer to: https://github.com/portainer/portainer/blob/develop/build/linux/Dockerfile
FROM portainer/portainer-ce:2.20.3 FROM portainer/portainer-ce:2.20.3
LABEL maintainer="websoft9<help@websoft9.com>" LABEL maintainer="websoft9<help@websoft9.com>"
LABEL version="2.20.3" LABEL version="2.20.3-rc1"
COPY --from=builder /init_portainer / COPY --from=builder /init_portainer /
ENTRYPOINT ["/init_portainer"] ENTRYPOINT ["/init_portainer"]

View File

@ -31,9 +31,12 @@ type Credentials struct {
} }
func main() { func main() {
// 检查初始化标志文件是否存在
if _, err := os.Stat(initFlagFilePath); err == nil { initFlagExists := fileExists(initFlagFilePath)
log.Println("Initialization has already been completed by another instance.") credentialFileExists := fileExists(credentialFilePath)
if initFlagExists || credentialFileExists {
log.Println("Initialization has already been completed by another instance or credentials are present.")
startPortainer() startPortainer()
return return
} }