diff --git a/package.json b/package.json
index 756e55d11a..4f8755901f 100644
--- a/package.json
+++ b/package.json
@@ -59,6 +59,7 @@
"onCommand:vscode-docker.images.runInteractive",
"onCommand:vscode-docker.images.tag",
"onCommand:vscode-docker.networks.configureExplorer",
+ "onCommand:vscode-docker.networks.create",
"onCommand:vscode-docker.networks.inspect",
"onCommand:vscode-docker.networks.prune",
"onCommand:vscode-docker.networks.refresh",
@@ -221,10 +222,15 @@
"group": "navigation@9"
},
{
- "command": "vscode-docker.networks.prune",
+ "command": "vscode-docker.networks.create",
"when": "view == dockerNetworks",
"group": "navigation@1"
},
+ {
+ "command": "vscode-docker.networks.prune",
+ "when": "view == dockerNetworks",
+ "group": "navigation@2"
+ },
{
"command": "vscode-docker.networks.refresh",
"when": "view == dockerNetworks",
@@ -1697,6 +1703,15 @@
"dark": "resources/dark/settings.svg"
}
},
+ {
+ "command": "vscode-docker.networks.create",
+ "title": "Create...",
+ "category": "Docker Networks",
+ "icon": {
+ "light": "resources/light/add.svg",
+ "dark": "resources/dark/add.svg"
+ }
+ },
{
"command": "vscode-docker.networks.inspect",
"title": "Inspect",
diff --git a/resources/dark/add.svg b/resources/dark/add.svg
new file mode 100644
index 0000000000..4d9389336b
--- /dev/null
+++ b/resources/dark/add.svg
@@ -0,0 +1,3 @@
+
diff --git a/resources/light/add.svg b/resources/light/add.svg
new file mode 100644
index 0000000000..01a9de7d5a
--- /dev/null
+++ b/resources/light/add.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/commands/networks/createNetwork.ts b/src/commands/networks/createNetwork.ts
new file mode 100644
index 0000000000..e84a659ad7
--- /dev/null
+++ b/src/commands/networks/createNetwork.ts
@@ -0,0 +1,34 @@
+/*---------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the MIT License. See LICENSE.md in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+import { window } from 'vscode';
+import { IActionContext } from 'vscode-azureextensionui';
+import { ext } from '../../extensionVariables';
+import { wrapDockerodeENOENT } from '../../utils/wrapError';
+
+export async function createNetwork(_context: IActionContext): Promise {
+
+ const name = await ext.ui.showInputBox({
+ value: '',
+ prompt: 'Name of the network'
+ });
+
+ const driverSelection = await ext.ui.showQuickPick(
+ [
+ { label: 'bridge' },
+ { label: 'host' },
+ { label: 'overlay' },
+ { label: 'macvlan' }
+ ],
+ {
+ canPickMany: false,
+ placeHolder: 'Select the network driver to use (default is "bridge").'
+ }
+ );
+
+ const result = <{ id: string }>await wrapDockerodeENOENT(() => ext.dockerode.createNetwork({ Name: name, Driver: driverSelection.label }));
+
+ window.showInformationMessage(`Network Created with ID ${result.id.substr(0, 12)}`);
+}
diff --git a/src/commands/registerCommands.ts b/src/commands/registerCommands.ts
index 8ca4591d2f..10b05caa8a 100644
--- a/src/commands/registerCommands.ts
+++ b/src/commands/registerCommands.ts
@@ -27,6 +27,7 @@ import { runAzureCliImage } from "./images/runAzureCliImage";
import { runImage, runImageInteractive } from "./images/runImage";
import { tagImage } from "./images/tagImage";
import { configureNetworksExplorer } from "./networks/configureNetworksExplorer";
+import { createNetwork } from "./networks/createNetwork";
import { inspectNetwork } from "./networks/inspectNetwork";
import { pruneNetworks } from "./networks/pruneNetworks";
import { removeNetwork } from "./networks/removeNetwork";
@@ -88,6 +89,7 @@ export function registerCommands(): void {
registerCommand('vscode-docker.images.tag', tagImage);
registerCommand('vscode-docker.networks.configureExplorer', configureNetworksExplorer);
+ registerCommand('vscode-docker.networks.create', createNetwork);
registerCommand('vscode-docker.networks.inspect', inspectNetwork);
registerCommand('vscode-docker.networks.remove', removeNetwork);
registerCommand('vscode-docker.networks.prune', pruneNetworks);