Skip to content

Instantly share code, notes, and snippets.

@mmarchini
Created June 5, 2017 15:49
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mmarchini/bc9df7b82127fea13612edf8bffdf96f to your computer and use it in GitHub Desktop.
Save mmarchini/bc9df7b82127fea13612edf8bffdf96f to your computer and use it in GitHub Desktop.
Docker Env converter from Windows to WSL
#!/usr/bin/env python3
from subprocess import run, PIPE
completed_process = run(["docker-machine.exe", "env", "--shell", "bash"], stdout=PIPE)
docker_env = completed_process.stdout.decode("ascii")
for line in docker_env.split("\n"):
if "DOCKER_CERT_PATH" in line:
env_var, path, _ = line.split('"')
path = path.replace("\\", "/")
drive, path = path.split(":", 1)
path = "/mnt/{}{}".format(drive.lower(), path)
line = '{}"{}"'.format(env_var, path)
print(line)
@RichardBronosky
Copy link

RichardBronosky commented Jul 24, 2018

This works:

eval $(docker-machine.exe env default --shell bash | sed 's?\\?/?g;s?C:/?/mnt/c/?g')

@storozhev
Copy link

thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment