Skip to content

Commit

Permalink
fix: docker中默认不打开浏览器
Browse files Browse the repository at this point in the history
  • Loading branch information
jeessy2 committed Dec 25, 2020
1 parent a75ffd9 commit 37ddbcf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ func main() {
} else {
url = fmt.Sprintf("http://[::1]:%d", addr.Port)
}
// 未找到配置文件才打开浏览器
// 未找到配置文件&&不是在docker中运行 才打开浏览器
_, err = config.GetConfigCache()
if err != nil {
if err != nil && !util.IsRunInDocker() {
go util.OpenExplorer(url)
}

Expand Down
15 changes: 15 additions & 0 deletions util/dockerUtil.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package util

import "os"

// DockerEnvFile Docker容器中包含的文件
const DockerEnvFile string = "/.dockerenv"

// IsRunInDocker 是否在docker中运行
func IsRunInDocker() bool {
_, err := os.Stat(DockerEnvFile)
if err != nil {
return false
}
return true
}

0 comments on commit 37ddbcf

Please sign in to comment.