浏览代码

[release] v0.13.0-unstable7

Yann Stepienik 1 年之前
父节点
当前提交
49d7dd7d4a
共有 2 个文件被更改,包括 11 次插入3 次删除
  1. 1 1
      package.json
  2. 10 2
      src/docker/api_updateContainer.go

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "cosmos-server",
   "name": "cosmos-server",
-  "version": "0.13.0-unstable6",
+  "version": "0.13.0-unstable7",
   "description": "",
   "description": "",
   "main": "test-server.js",
   "main": "test-server.js",
   "bugs": {
   "bugs": {

+ 10 - 2
src/docker/api_updateContainer.go

@@ -5,6 +5,7 @@ import (
 	"net/http"
 	"net/http"
 	"os"
 	"os"
 	"fmt"
 	"fmt"
+	"strings"
 
 
 	"github.com/azukaar/cosmos-server/src/utils"
 	"github.com/azukaar/cosmos-server/src/utils"
 	containerType "github.com/docker/docker/api/types/container"
 	containerType "github.com/docker/docker/api/types/container"
@@ -82,9 +83,16 @@ func UpdateContainerRoute(w http.ResponseWriter, req *http.Request) {
 		if(form.Devices != nil) {
 		if(form.Devices != nil) {
 			container.HostConfig.Devices = []containerType.DeviceMapping{}
 			container.HostConfig.Devices = []containerType.DeviceMapping{}
 			for _, device := range form.Devices {
 			for _, device := range form.Devices {
+				deviceHost := strings.Split(device, ":")[0]
+				deviceCont := deviceHost
+
+				if strings.Contains(device, ":") {
+					deviceCont = strings.Split(device, ":")[1]
+				}
+
 				container.HostConfig.Devices = append(container.HostConfig.Devices, containerType.DeviceMapping{
 				container.HostConfig.Devices = append(container.HostConfig.Devices, containerType.DeviceMapping{
-					PathOnHost:        device,
-					PathInContainer:   device,
+					PathOnHost:        deviceHost,
+					PathInContainer:   deviceCont,
 					CgroupPermissions: "rwm",
 					CgroupPermissions: "rwm",
 				})
 				})
 			}
 			}