From 202095527094d968826eb2045bc57966ba5c10d0 Mon Sep 17 00:00:00 2001 From: Gucheng Wang Date: Wed, 15 Jun 2022 01:20:00 +0800 Subject: [PATCH] Fix cannot support old Docker version bug, revert PR: https://github.com/casdoor/casdoor/pull/606 --- conf/conf.go | 8 +++++++- docker-compose.yml | 2 -- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/conf/conf.go b/conf/conf.go index 7ef49917..7088c676 100644 --- a/conf/conf.go +++ b/conf/conf.go @@ -17,6 +17,7 @@ package conf import ( "fmt" "os" + "runtime" "strconv" "strings" @@ -61,7 +62,12 @@ func GetBeegoConfDataSourceName() string { runningInDocker := os.Getenv("RUNNING_IN_DOCKER") if runningInDocker == "true" { - dataSourceName = strings.ReplaceAll(dataSourceName, "localhost", "host.docker.internal") + // https://stackoverflow.com/questions/48546124/what-is-linux-equivalent-of-host-docker-internal + if runtime.GOOS == "linux" { + dataSourceName = strings.ReplaceAll(dataSourceName, "localhost", "172.17.0.1") + } else { + dataSourceName = strings.ReplaceAll(dataSourceName, "localhost", "host.docker.internal") + } } return dataSourceName diff --git a/docker-compose.yml b/docker-compose.yml index 0f27fb26..69ebf2d6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,8 +12,6 @@ services: - db environment: RUNNING_IN_DOCKER: "true" - extra_hosts: - - "host.docker.internal:host-gateway" volumes: - ./conf:/conf/ db: