changeset 946:f3b989a8f2bc

Added utility to activate Windows based docker-machine in WSL.
author Oleksandr Gavenko <gavenkoa@gmail.com>
date Tue, 06 Oct 2020 19:44:05 +0300
parents b14781b95dfa
children 9929622f05c0
files .bashrc
diffstat 1 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/.bashrc	Wed Sep 09 00:30:54 2020 +0300
+++ b/.bashrc	Tue Oct 06 19:44:05 2020 +0300
@@ -288,3 +288,23 @@
     git tag --contains "$1" --format '%(objectname)';
       );
 }
+
+mywsl-docker-enable() {
+  if [[ -z "$1" ]]; then
+    set default
+  fi
+  while IFS= read -r line; do
+    if [[ ! "$line" =~ ^export ]]; then
+      continue
+    fi
+    if [[ "$line" =~ DOCKER_CERT_PATH ]]; then
+      local p="${line#*=}"                  # Strip leading 'export var='.
+      p="${p#\"}"                           # Strip leading ".
+      p="${p%\"}"                           # Strip final ".
+      export DOCKER_CERT_PATH=$(wslpath -u $p)
+      export DOCKER_1=123
+    else
+      eval "$line"
+    fi
+  done < <(docker-machine.exe env --shell bash "$1")
+}