Skip to content

Instantly share code, notes, and snippets.

@strarsis
Forked from mmarchini/docker-env
Created January 16, 2018 15:46
Show Gist options
  • Save strarsis/c044317791cd9d856e34472b6433af8b to your computer and use it in GitHub Desktop.
Save strarsis/c044317791cd9d856e34472b6433af8b 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment