1Panel/backend/app/service/docker_test.go

33 lines
648 B
Go
Raw Normal View History

2022-11-14 19:19:42 +08:00
package service
import (
"encoding/json"
"fmt"
"io/ioutil"
"strings"
"testing"
)
func TestDocker(t *testing.T) {
file, err := ioutil.ReadFile("/opt/1Panel/docker/daemon.json")
if err != nil {
fmt.Println(err)
}
var conf daemonJsonItem
deamonMap := make(map[string]interface{})
if err := json.Unmarshal(file, &deamonMap); err != nil {
fmt.Println(err)
}
arr, err := json.Marshal(deamonMap)
if err != nil {
fmt.Println(err)
}
_ = json.Unmarshal(arr, &conf)
for _, opt := range conf.ExecOpts {
if strings.HasPrefix(opt, "native.cgroupdriver=") {
fmt.Println(strings.ReplaceAll(opt, "native.cgroupdriver=", ""))
}
}
}