diff --git a/db/patch-add-docker-columns.sql b/db/patch-add-docker-columns.sql index fdde41705..564756678 100644 --- a/db/patch-add-docker-columns.sql +++ b/db/patch-add-docker-columns.sql @@ -7,4 +7,7 @@ ALTER TABLE monitor ALTER TABLE monitor ADD docker_container VARCHAR(255); +ALTER TABLE monitor + ADD docker_type VARCHAR(255); + COMMIT; diff --git a/server/model/monitor.js b/server/model/monitor.js index b75500ec2..d8a4be238 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -79,6 +79,7 @@ class Monitor extends BeanModel { pushToken: this.pushToken, docker_container: this.docker_container, docker_daemon: this.docker_daemon, + docker_type: this.docker_type, notificationIDList, tags: tags, }; @@ -358,13 +359,18 @@ class Monitor extends BeanModel { "Accept": "*/*", "User-Agent": "Uptime-Kuma/" + version, }, - socketPath: this.docker_daemon, httpsAgent: new https.Agent({ maxCachedSessions: 0, // Use Custom agent to disable session reuse (https://github.com/nodejs/node/issues/3940) rejectUnauthorized: ! this.getIgnoreTls(), }), }; + if (this.docker_type === "socket") { + options.socketPath = this.docker_daemon; + } else if (this.docker_type === "tcp") { + options.baseURL = this.docker_daemon; + } + debug(`[${this.name}] Axios Request`); let res = await axios.request(options); if (res.data.State.Running) { diff --git a/server/server.js b/server/server.js index 7495cfb8a..ac68769da 100644 --- a/server/server.js +++ b/server/server.js @@ -590,6 +590,7 @@ exports.entryPage = "dashboard"; bean.pushToken = monitor.pushToken; bean.docker_container = monitor.docker_container; bean.docker_daemon = monitor.docker_daemon; + bean.docker_type = monitor.docker_type; await R.store(bean); diff --git a/src/languages/en.js b/src/languages/en.js index ae9fa5262..ade50373d 100644 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -364,4 +364,7 @@ export default { "Container Name / ID": "Container Name / ID", "Docker Daemon": "Docker Daemon", "Docker Container": "Docker Container", + "Docker Type": "Connection Type", + docker_socket: "Socket", + docker_tcp: "TCP / HTTP", }; diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 86c35ef04..b80b9a269 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -125,6 +125,20 @@ + + +
+ + +
+
@@ -458,6 +472,7 @@ export default { dns_resolve_server: "1.1.1.1", docker_container: "", docker_daemon: "/var/run/docker.sock", + docker_type: "socket", }; for (let i = 0; i < this.$root.notificationList.length; i++) {