Running Docker containers on Bash on Windows

When the Windows Subsystem for Linux (WSL) – or, as most people even at Microsoft often refer to it – Bash on Ubuntu on Windows – was announced on Microsoft’s Build conference 2016, a world of new tools opened up to us Windows devs. Personally, I love being able to choose between PowerShell, Bash or plain old cmd when I want to script something. And it’s always bugged me that I couldn’t get Docker working from Bash on Windows – until now.

The original title of this post was “Running Docker from Bash on Windows”, but that would have been a slight overstatement. Docker requires access to quite a of lot system calls which aren’t necessarily all implemented on Windows, so getting the engine running under the WSL is probably not so easy. Instead, we’ll run the Docker Engine on Windows, and connect to it from Bash. This also has the advantage that you can start a container from PowerShell and interact with it from Bash, or the other way around – in other words, your computer will still feel just like one machine.

Here’s how to do it:

1. Install Docker on Windows

To install the Docker engine on Windows, just go to and download the appropriate distribution. Also, make sure hardware virtualization is enabled and Hyper-V is installed, lest the engine won’t start.

Shortcut: Install Windows 10 Creators Update

With Windows 10 Creators Update, accomplishing all of this has become a lot simpler, since it allows you to run Windows executables from Bash. Just add these two lines to your .bashrc (and reload your environment) and you’re done!

export PATH="$HOME/bin:$HOME/.local/bin:$PATH"
export PATH="$PATH:/mnt/c/Program\ Files/Docker/Docker/resources/bin"
alias docker=docker.exe
alias docker-compose=docker-compose.exe

You can now run docker --version from Bash, and you don’t even have to read the rest of this blog post :)

Making it work on Windows 10 Anniversary Edition

To install Docker on the WSL, you’ll need to jump through a few more hoops. There’s a description for Ubuntu in general here, which works for the WSL as well, with the exceptions of some of the optional steps. Here’s what I did:

# Install packages to allow apt to use a repository over HTTPS
$ sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
# Add Docker's official GPG key
$ curl -fsSL | sudo apt-key add -
# Set up the repository
sudo add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"
# Update source lists
sudo apt-get update
# Install Docker
sudo apt-get install docker-ce

Of course, there’s also the option of downloading and extracting the binaries we’ll need, and put them somewhere in your PATH. There are instructions here for how to get the latest version.

Where did that get us?

We now actually have the Docker engine installed on both Windows and the WSL, but it isn’t started on either. The Windows installer helpfully created a Docker shortcut on the desktop and/or in the Start menu – use that to start the Docker engine. Then, you can try running e.g. docker images from PowerShell and from Bash:


PS C:\> docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

We haven’t created any images yet, so that’s fine.


$ docker images
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Clearly unsatisfying. But with one or two extra steps, we’ll get it all working.

2. Connect Docker on WSL to Docker on Windows

Running docker against an engine on a different machine is actually quite easy, as Docker exposes a TCP endpoint which the CLI can attach to. The endpoint uses TLS, which means we have to set up the client on the WSL side to recognize the certificates that the Docker machine on the Windows side uses (thanks Alan for the tip!):

export DOCKER_HOST=tcp://  // your Docker IP
export DOCKER_CERT_PATH=/mnt/c/Users/YOUR_USERNAME/.docker/machine/certs

With that done, all we need to do is instruct the CLI under Bash to connect to the engine running under Windows instead of to the non-existing engine running under Bash, like this:

$ docker -H tcp:// images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

Much better!

Having to specify that flag all the time is annoying, though. Luckily, there’s a better way (thanks Dave!) – export an environment variable which instructs Docker where to find the host engine:

export DOCKER_HOST='tcp://'

Of course, we’d want these changes in .bashrc  to make them sticky:

$ echo >> ~/.bashrc <<EOF
# Connect to Docker on Windows
export DOCKER_CERT_PATH=/mnt/c/Users/YOUR_USERNAME/.docker/machine/certs
export DOCKER_HOST='tcp://'
$ source ~/.bashrc

Now, running docker commands from Bash works just like they’re supposed to.

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

Mission accomplished!

The versions used in this post

Of course, things like these might always have dependencies of the versions of the tools you’re using. In this blog post, I’ve been using the following versions:

Windows 10 Pro Anniversary Edition (Version 1607, OS Build 14393.1066)
Windows 10 Pro Creators Update (Version 1703, OS Build 15063.138)
WSL Ubuntu
14.04.5 LTS
Docker on Windows
17.03.1-ce, build c6d412e
Docker on Ubuntu
17.03.1-ce, build c6d412e

This Post Has 96 Comments

  1. Romain Prevost

    Hi !

    Thank you for your update with windows Creator’s update, but I would just add something, WSL can launch windows executables but you have to provide the extension, so to launch docker you would have to type docker.exe which is not very practical.

    Just add aliases for docker.exe and docker-compose.exe and you’re done :)

    1. Florian

      I can not recommend using docker.exe (neither by alias nor explicit). When using docker.exe, you can not use -ti (terminal interactive) anymore, because it does not find find your unix shell.

      1. Tomas Aschan

        I know – and this is an issue if you need to run interactive commands using docker. Most of the time, though, I find that I don’t actually need those – and if I do, the setup in this blog post doesn’t in any way hinder me from falling back to using Docker from e.g. Powershell instead.

    2. Naseer

      Hi, I would like to appreciate efforts! I followed all the steps but getting an error: “unable to resolve docker endpoint: open /mnt/c/Users/NASEER/.docker/machine/certs/ca.pem: no such file or directory”.
      Help is highly apprecited!
      Thank you!

  2. Steinar Flatland

    Worked perfectly. Great stuff. Thank you!

  3. Dave C.

    Instead of
    echo “alias docker=’docker -H tcp://′” >> ~/.bashrc

    echo “export DOCKER_HOST=”tcp://” >> ~/.bashrc

    And regarding Romain Prevost’s alias suggestion: I’ve run into some issues using docker-compose with this setup. I found it easier to install docker-ce and docker-compose under WSL then just exporting the variable above.

    1. strarsis

      I got docker running in Windows 10 Home Premium and WSL up to the point where I can list containers / pull images,
      see these notes for reproducing the setup:

      However, starting containers with docker-compose doesn’t work yet, I get an error message like:
      ERROR: for Cannot start service php: oci runtime error: container_linux.go:262: starting container process caused “chdir to cwd (\”\”) set in config.json failed: no such file or directory”
      I haven’t solved this issue yet, I tried several things, like wrapping the windows-native docker.exe in shell.
      How can I fix this with my current setup?

  4. Disha

    Great blog, I could successfully install Docker on windows.

  5. Mark C

    Trying this on May 15, 2017, using docker version 17.03.1-ce-win12 (12058), between parts 2 and 3 it was also necessary to select the following option from Docker > Settings > General:
    “Expose daemon on tcp://localhost:2375 without TLS”.
    Note the warning underneath that option, in case it is important to you:
    “Exposing daemon to TCP without TLS helps legacy clients connect to teh daemon. It also makes yourself vulnerable to remote code execution attacks. Use with caution.”

    Without doing that, you continue to get the connection error, “Cannot connect to the Docker daemon…”

    1. Tomas Lycken

      I realized this would probably be necessary when I read the release note about this update, but I hadn’t had time to experiment with it and come up with a solution. Thanks for posting back here!

      1. Leo

        Hey Guys,
        I wrote a small script, that gets loaded in bashrc, it mounts /mnt/c to /c so you can do host mounts, and it also creates an alias for docker-machine to generate the right docker-machine env exports, including the secured port and certs path. Can you guys try it out see if it’s useful ?

  6. Ronny Carlansson

    A very good thread! Been searching for this a while :)
    Had the same problem as Mark C – “Expose daemon on tcp://localhost:2375 without TLS”.
    Took a while before I read his comment…


    1. Tomas Lycken

      Glad you found it helpful!

      I’ve updated the post to make this point clearer; hopefully future readers won’t have to stumble on this.

  7. Peter

    Thanks for the really great article by the way.
    Looked like a very simple few steps to install docker, however I ran into a few issues.
    I have windows 10 creator update installed on my machine. However I only have the Home edition and therefore cannot install the windows version docker. I instead followed your instructions to install docker on WSL.
    I have set the DOCKER_HOST variable.
    However when I try and run docker ps I get the following error:
    Cannot connect to the Docker daemon at tcp:// Is the docker daemon running?
    If this is an issue with the TCP endpoint being turned off then how would I solve this without having docker installed on Windows?

  8. Leo

    The Creators Update approach works great! But as Romain Prevost mentioned I had to locate the program with docker.exe or docker-compose.exe instead.

    Also I was cloning my repositories into the Linux filesystem, which causes a warning about “Unable to translate current working directory. Using C:\WINDOWS\system32” because your windows programs cannot open Linux files. It’s a WSL limitation, but I really think it should just error out instead of giving a warning.

  9. Adrian

    I installed docker under WSL as you had it, and this worked fine, running the Docker engine installed under Windows. Wanting to remove the WSL installation and just run the Windows Docker from Bash with just the path additions you mentioned (when running the CU), I tried to “sudo apt remove docker-ce”, but this results in an error, and the package is not removed. Can you confirm that you also can’t remove the docker-ce package and that something gets borked when installing Docker under WSL?

  10. Karl

    Working with Windows 10 Home, Creator’s Update, WSL, Docker Toolkit.

    1. strarsis

      I also got the same setup (Windows 10 Home, Creator’s Update, WSL, Docker Toolkit).

      Running docker results in error:

      error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.29/containers/json?all=1: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.

      Also as root (sudo) I get the same error that the client should be elevated.

      In .bashrc:

      # Docker
      export PATH=”$HOME/bin:$HOME/.local/bin:$PATH”
      export PATH=”$PATH:/mnt/c/Program\ Files/Docker\ Toolbox”
      alias docker=docker.exe
      alias docker-machine=docker-machine.exe

      I also have same issues in normal windows cmd, also using docker.exe.
      Created a new docker-machine using `docker-machine create default`.
      Copied + evaluated the commands from `docker-machine env`.

      Docker error in cmd with `docker ps`:
      could not read CA certificate “C:\\Users\\\\.docker\\ca.pem”: open C:\Users\\.docker\ca.pem: The system cannot find the file specified.

      Regenerated the certs using `docker-machine regenerate-certs` [y].
      Still same error, cannot find the ca.pem.

      Thanks in advance and with best regards!

      1. Tomas Lycken

        Just to be sure; you did double-check that the daemon is running, right? The error message is a bit misleading – I’ve stumbled several times because I stopped reading before I got to `This error may also indicate that the docker daemon is not running.`…

          1. Tomas Lycken

            Thanks a lot for getting back with this info!

  11. Robert Jackson

    Thanks a lot. Running docker on bash shell under windows is fantastic. I also found it easier to just use the second method.

  12. Patrick Roza

    I prefer using the docker-ce package on bash for windows even in the creators update because running windows executables from bash do not support signals like SIGINT, e.g ctrl+c (BREAK), which I find important in my docker/docker-compos endevours ;-)

  13. Brian Lloyd-Newberry

    Just to save some people time, in the newer version of Docker for Windows it doesn’t listen on tcp:// or tcp://localhost:2375 by default. You need to go into the settings and enable it for the windows docker daemon by checking the “Expose daemon on tcp://localhost:2375 without TLS’ option. Note. this does open things up for a remote execution attack. The other option is setting up SSL keys and TLS, but that is for another day.

    You’ll get: the following:
    > docker run hello-world
    docker: Cannot connect to the Docker daemon at tcp:// Is the docker daemon running?.
    See ‘docker run –help’.

  14. Jeremiah

    not sure what I am doing wrong here, used the ‘shortcut’ as I am on creators update, but when I run docker.exe from bash, i get an error: Unable to translate current working directory. Using C:\windows\system32

  15. Patrick

    If you want to actually run the docker instances on WSL (you’ll get better performance) you should modify this process so that after installing docker on WSL you change the docker socket to use a loopback TCP socket instead of a *nix socket file as WSL currently doesn’t support *nix socket files. then you can either connect using the windows docker or you can just use it from command line WSL.

  16. Anna Bell

    This does not work for me, I have the creator update with the latest bash environment (16.04). When I add those 2 lines to .bashrc and after restart of bash I try to run docker –version, it tells me it can’t find docker. How to solve it?

    1. Tomas Lycken

      What happens if you run `docker.exe –version`?

      Although Creators Update lets us run windows executables from the WSL, it doesn’t automatically resolve file extensions the way Windows does. You can add `alias docker=docker.exe` to simulate the behavior for this use case, though :)

    2. Brad C

      I have the same problem. It doesn’t work for me whether I run “docker –version” or “docker.exe –version”.

  17. Dan

    Why do volumes not seem to work at all with docker-compose?

    Soemthing to do with the C:/ vs /mnt/c/ paths?

    1. Dan

      ERROR: for client Cannot start service client: oci runtime error: container_linux.go:262: starting container process caused “process_linux.go:339: container init caused \”ro
      otfs_linux.go:57: mounting \\\”/mnt/c/var/www/react-app.local/client/package.json\\\” to rootfs \\\”/var/lib/docker/overlay2/47d9e084699b9b8dd832916012c288853d46558cd4a4521c1
      80a7b4caf32bbf4/merged\\\” at \\\”/var/lib/docker/overlay2/47d9e084699b9b8dd832916012c288853d46558cd4a4521c180a7b4caf32bbf4/merged/var/www/client/package.json\\\” caused \\\”
      not a directory\\\”\””
      : Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

      1. Tomas Lycken

        Yes, probably a path/file system issue. I haven’t explored docker-compose under WSL deeply; I tend to want to use bash when I script one-offs and try stuff out, but once I have it in my compose file I see no reason not to start the stack directly from Windows.

        1. strarsis

          docker and docker-compose run well on WSL for me. But docker-compose volumes don’t work correctly.
          On the other hand, docker.exe and docker-compose.exe don’t work correctly in WSL,
          but docker-compose.exe volumes probably would.

  18. Andrew Lozoya

    I dont understand the implications of doing this, just so you can use bash… isnt the daemon still running on a hyperv VM which in itself is a linux kernel? Or am I way off base.

    1. Tomas Lycken

      The reason for doing this is not to make Docker work any differently – you’re entirely correct, it’s just the same daemon still running on HyperV as if you use Docker from powershell or cmd. Rather, it’s to enable *using* Docker in bash scripts, e.g. for build or test orchestration. It’s of course possible to do those things in a Docker container as well, but it’s a little tricky to set it up so that you can work with Docker from within Docker, so I find this way much easier.

  19. Andrew Lozoya

    Where is the .bashrc actually located? I am assuming you meant %localappdata%\Lxss\rootfs
    but when i add the lines
    PATH=”$PATH:/mnt/c/Program\ Files/Docker/Docker/resources/bin”

    i get thisbash: /root/.bashrc: Input/output error
    root@XXXX:/mnt/c/Users/lozoyaa/Desktop# docker –version
    The program ‘docker’ is currently not installed. You can install it by typing:
    apt install

  20. Andriy Minchenko

    Worked perfectly. (Windows 10 Pro, version 1607, build 14393.1593 +Docker version 17.06.2-ce, build cec0b72 )
    Thanks a lot!

  21. Taehee Jang

    Hello, I had a great help from your blog!
    I tested Windows 10 1703 June 2017 update & WSL Ubuntu 16.04.2 LTS, and it worked very well!

    Would you mind if I introduce this method to Ubuntu Korea Seminar? I will definitely write down this URL page.
    Many people have asked about how to run docker Bash on Ubuntu on Windows. I think more people will use Bash on Windows by using this method.
    I appreciate again your solution and effort!!

    1. Tomas Lycken

      Glad it helped you! I don’t mind you sharing it at all, quite the opposite!

  22. Enes

    Hi guys,

    I’ve did everything as described in the article and docker is working just fine. But docker-compose is not recognized as the command…is there anything special that I need to do for docker-compose. When using powershell this command is recognized and it is working.


  23. Matt

    GOD DAMN I LOVE YOU LOL, this was exactly what I needed to know to solve my issue.

  24. Rashid Mahmood


    Thank you it is really helpful.

  25. Marian

    When I searched for “install docker on Ubuntu on Windows” I was actually hoping to find info that “it just works!” (no docker for windows install, just Ubuntu).
    That doesn’t seem to be the case :)
    My problem is I also have VirtualBox for different projects at work. And VB stops working after enabling Hyper-V.
    So… I was hoping that I could simply install docker in my WSL – like I would simply be booted under another OS (Ubuntu) – and that it wouldn’t have anything to do with Windows and it would simply work, without enabling Hyper-V in Windows – which causes a blue screen once I try to start up a VM from VirtualBox.
    When is VirtualBox going to fix this? :(

    1. Tomas Lycken

      Well, WSL is a real Ubuntu system, but it doesn’t have all the features of Ubuntu installed on bare metal – virtualization is one of the things it doesn’t have. So, running docker natively under WSL is probably not going to happen anytime soon. And although Ubuntu doesn’t have anything named Hyper-V, you still need to enable hardware virtualization to enable Docker on a native Ubuntu host – so if VirtualBox doesn’t support “nested” virtualization, running Docker inside VirtualBox is going to be difficult.

      Are you successfully running Docker in Windows inside your virtual machines in VirtualBox? If not, maybe it’s possible to run Docker on the host system, and then mount the Docker socket onto the VirtualBox guest (just as you’d do to enable running Docker inside Docker containers)?

  26. Brian Bulkowski

    Hi – I didn’t read through all the responses, but since you’re so highly ranked on google for this problem you might want to update the instructions.

    First, you don’t need to change the extra environment variables, you do need to link or rename ( I prefer linking ) docker to docker. After you install docker, the environment variables are set also in WSL. One can easily test this by, with a fresh install, attempting to run docker.exe without the environment variables. Worked! Now I only need to figure out the best way to soft-link – I’m assuming I put files in /usr/local/bin like I usually would.

    Second, there’s a lot of comments about changing the default listener, so I suppose those are correct too.

    Thanks for the blog post – this tech is moving fast. I hope you find time to update.

    1. Tomas Lycken

      Thanks for these comments! Yes, keeping this post up-to-date with instructions that actually work is important to me, so I do want to take the time to get this right if there’s an error somewhere.

      Just to be sure: you did notice that most of the instructions here are not for the current version of Windows, right? With Creators Update, you really don’t need to do anything – you can just run docker.exe and it works, since they have greatly improved WSL/Windows interop over Anniversary Edition. (You might have to add the Docker installation directory to your PATH in WSL, but I’m not sure – it might be there automatically. You might also, as I suggest in the post, want to alias docker=docker.exe just to make it “feel” more like on Linux – but it’s by no means necessary to be able to run Docker commands.)

      Unfortunately, I don’t have access to a system with Anniversary Edition now, so I can’t test anything there, but are you saying that you don’t need echo "export DOCKER_HOST='tcp://'" >> ~/.bashrc anymore? Or what exactly is it that I should change? :)

  27. Alexander Wagner

    First of all, I found that using Windows installer from docker page already adds “C:\Program Files\Docker\Docker\Resources\bin” to PATH although it should actually be “C:\Program Files\Docker\Docker\resources\bin”, i.e. lower case “r” in “resources”. Since WSL inherits PATH form Windows, it worked for me without adding extra pointers in .bashrc.

    Second, I am surprised that it seems to have worked for some people here using Windows 10 Home. I tried it and it didn’t work as Docker requires Hyper-V enabled which apparently is only possible under Windows Pro and Enterprise.

    Third, I found that you get the error “Unable to translate current working directory. Using C:\WINDOWS\system32” when running Docker in WSL in some directories, e.g. home (~), but not when running it in others, e.g. in “/mnt/c/Program\ Files/Docker/Docker/resources/bin”. This is apparently expected as some directories have no Windows equivalent, see this Github issue

    Thanks for the post! Happy dockering.

  28. Sherryl Manalo

    Thanks for your blog post! Exactly what I needed and worked like a charm.

  29. DJ

    ^^ Thank you much…..kind of a tangential question, but thought this might be a good place to ask: Is this going to be the pattern in general for native Linux apps on native Windows do you think? I guess it might be as you indicate with the hyperv in the comment above, depends on the prereqs for the specific software?

    1. Tomas Lycken

      No, I don’t think so. This is required specifically because Docker uses all kinds of special things from the kernel in order to properly virtualize the machine, and those aren’t available in WSL. However, for most Linux apps, WSL is perfectly capable to cater, which means that `apt-get install` will be the only setup step you need.

    1. Tomas Lycken

      I don’t think it’s a general problem in version 1709 – I’m running that version with Hyper V and Docker working fine. (I do have some problems with virtualization sometimes, related to running Win10 on a Macbook, but Apple is more at fault than Microsoft for that…)

  30. Fabian K.

    Worked great, thank you!

  31. Kunal

    Nice article! Really helped a lot.
    Is there a way to create docker-machines on “Bash on Ubuntu on Windows”, looking to create multiple hosts as done using hyper-v driver in windows. I would like to test a swarm cluster with multiple hosts.

    1. Tomas Lycken

      No, it’s not – the WSL are lacking some of the features needed for Docker’s virtualization model, so you won’t be able to run a docker host under WSL (at least not in the foreseeable future).

      If you want to test how it’s like to run a Swarm cluster you’ll have to run some other virtualization software between your Windows installation and Docker – or just join another physical machine.

  32. Bartol

    That’s nice, but unfortunately it doesn’t work for me:
    Windows 10 Enterprise 1709 (build 16299.125)
    Docker version 17.09.1-ce, build 19e2cf6
    Ubuntu 16.04.3 LTS

    Docker on Windows works well. When I try to run it in Ubuntu (version from Windows Store, under old Bash for Windows it doesn’t work either) I get:
    $ docker –version
    The program ‘docker’ is currently not installed. You can install it by typing:
    sudo apt install
    $ docker.exe
    docker.exe: command not found

    I have proper paths in PATH. And it doesn’t matter if paths are written with ” ” or “\ ” (which is visible for Ubuntu). I can get to
    /mnt/c/Program\ Files/Docker/Docker/resources/bin, but can’t run docker.

    What else can I do to have it working?

    1. Tomas Lycken

      To be honest, I don’t know; I haven’t tested this with Windows 10 Enterprise edition, but other than that it seems to me that you have everything in place. My setup is working, and I haven’t done anything but what’s in this blog post.

      Things I’d try (one by one):

      * source `.bashrc` or `.bash_aliases` or wherever you put the aliases
      * Run other `exe` files from Bash
      * Reinstall Docker

      Do report back if you get it working!

      1. Bartol

        Thanks for reply. By accident I’ve got it working in two steps (kind of blind shots):
        1. I ran “Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux” in PowerShell.
        2. I got back standard paths in $PATH (without “\ ” in names), which hadn’t work earlier.

        Probably I had some old configuration as I’d installed WSL for the first time about a year ago and I’d changed old Bash for Windows to Ubuntu from Store yesterday.

        Thanks for your blog post! It’s very helpful. I even didn’t know it’s possible to run Windows apps on Ubuntu on Windows.

  33. Zubair Ahmed

    Thanks Tomas Lycken,
    This article saved my day!!
    I was able to configure docker succesfully.

  34. glashio

    docker attach mynginx
    tls: oversized record received with length 20527

    docker -D exec -it mynginx bash
    tls: oversized record received with length 20527
    docker images, docker run, docker ps, docker inspect
    all runs flawless from Ubuntu Bash to Windows Docker. But
    docker attach, docker exec
    always run in this error. Anybody?

  35. Jay Bose

    Hey, just a “Thank you” note.
    I was concerned, but came upon this, and got some hope.
    Not to mention when I got it all working!

    Thank you.

  36. Andrew

    These instuctions are not great.

    – Load bash, in your starting folder edit the file .bashrc and add the following lines then close bash. Then you can call docker as normal

    export PATH=”$HOME/bin:$HOME/.local/bin:$PATH”
    export PATH=”$PATH:/mnt/c/Program\ Files/Docker\ Toolbox”
    alias docker=docker.exe
    alias docker-machine=docker-machine.exe

    1. Tomas Lycken

      Thanks for the feedback!

      I’ve updated the instructions to be a little clearer, hope that helps!

  37. Merelda

    Works for me 100% first time round, thanks!

  38. sagar

    thank you

  39. Axel Boross

    Great Job, functionallity without problems. You are my Hero. I would like to commit a german tutorial on my website with your origin source

  40. Lalit Kumar


    I am able to run the docker images command and can see 2 images that I did using docker pull. But same fails with following error when I use docker run hello-world

    “tls: oversized record received with length 20527”

    Any help is appreciated

    Lalit Kumar

  41. Using alias has some issues when using docker with Makefile.
    Because Makefile does not know anything about shell aliases.
    So I replace:
    alias docker=docker.exe
    alias docker-compose=docker-compose.exe
    mkdir -p ${HOME}/bin
    if [ ! -f ${HOME}/bin/docker ]; then
    echo “/usr/bin/docker not found! Let’s create and enjoy it.”
    ln -s /mnt/c/Program\ Files/Docker/Docker/resources/bin/docker.exe ${HOME}/bin/docker

    if [ ! -f ${HOME}/bin/docker-compose ]; then
    echo “docker-compose not found! Let’s create and enjoy it.”
    ln -s /mnt/c/Program\ Files/Docker/Docker/resources/bin/docker-compose.exe ${HOME}/bin/docker-compose

    1. generalleespeaking

      The simplest answer is always the best. I couldn’t use the aliases because I was running docker in a shell script – which doesn’t expand aliases. A link is the simplest answer. Thank you.

  42. Lap

    Thanks for your help. You save my life :)

    1. Tomas Lycken

      Nice – I didn’t know about that! I’ve updated the post accordingly :)

    2. Peter

      What do you do if `.docker/machine/certs` does not exist?

      A `docker-machine create default` fails because, obviously, there is no virtualbox installed (why should I with WSL and HyperV available).
      Creating CA: C:\Users\peter\.docker\machine\certs\ca.pem
      Creating client certificate: C:\Users\peter\.docker\machine\certs\cert.pem
      Running pre-create checks…
      Error with pre-create check: “VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path”

      docker -H ps
      Cannot connect to the Docker daemon at tcp:// Is the docker daemon running?

      Version: 18.06.1-ce
      API version: 1.38
      Go version: go1.10.3
      Git commit: e68fc7a
      Built: Tue Aug 21 17:21:34 2018
      OS/Arch: windows/amd64
      Experimental: false

      Version: 18.06.1-ce
      API version: 1.38 (minimum version 1.12)
      Go version: go1.10.3
      Git commit: e68fc7a
      Built: Tue Aug 21 17:29:02 2018
      OS/Arch: linux/amd64
      Experimental: false

  43. Kyle

    I tried to follow the new instructions adding `DOCKER_CERT_PATH` and `DOCKER_TLS_VERIFY` and it actually broke things for me. Probably because I’m not using Docker Toolbox, but Docker for Windows.

    Thanks for the tutorial!

  44. Eemeli Kantola

    Great article, thank you! However, I did one thing differently to enable running scripts that reference the `docker` command, as aliases are not passed to subshells or processes. Instead, I created simple wrapper scripts under `~/bin` that just execute the Docker commands with full paths and copy all arguments to them, and ensured `~/bin` is in PATH. For example, `~/bin/docker`:

    #! /bin/bash
    docker.exe “$@”

  45. Nick

    Hi Tomas, I was wondering if using interoperability (using the Docker Win executables directly), were you able to successfully exec into the containers? When I tried `docker exec -it … bash`, I get `the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty’`. Not too sure what’s the best way around it.

    1. Tomas Lycken

      Yeah, that’s a little annoying, but it’s only in Bash that it fails. If I need to `exec` into a container (I try to not have to do that) I usually do it from PowerShell instead, where it works as expected. (Just make sure that the `docker.exe` is in your PowerShell path as well.)

  46. LN

    Thanks for the post it is great! One question though, if I want to push an image to an External registry, like or ACR, I always get authentication required from the WSL terminal but not from Windows CMD, is it posible to push images to an External registry from WSL directly, for example to use in Visual Studio Code.

    1. Tomas Aschan

      Yes, it’s possible. However, you have to keep in mind which Docker client it is you want to authenticate against the registry, and how to do that properly.

      For example, I’m running the Azure CLI both under WSL and under Windows, but I’ve symlinked `docker` in WSL to point to `docker.exe` installed with Docker for Desktop (i.e. on Windows). Therefore, when I want to do `az acr login` to authenticate my Docker client with the ACR registry, I have to do that from Windows, since the `az` command under WSL fails to talk to Docker correctly. Once you’ve authenticated properly, you should be able to push and pull images from ACR also when invoking Docker from WSL.

  47. Marcin Balcerzyk

    Just a comment: my docker does not have certificates in the specified path, so I commented out the following lines:
    #export DOCKER_CERT_PATH=/mnt/c/Users/YOUR_USERNAME/.docker/machine/certs
    #export DOCKER_TLS_VERIFY=1
    … and the connection to docker on Windows 10 on Ubuntu 18.04 seem to work fine. Maybe it is not safe, but I run docker only localy and do not open it for external world.

  48. angrye

    Can someone elaborate more on Step 2? Where do I get my Docker IP? I’ve got the base install on Windows 10 Anniversary.

  49. kaizokun

    And what “your docker Ip” is supposed to be ?

    1. Tomas Aschan

      Hm – that was a typo; I reset that variable a couple of lines below. To reduce confusion, I’ve reduced the line you’re referring to, and everything should “just work” now.

  50. David Haughton

    Great blog.. love it.. thanks

  51. Walter

    Two days burning my brain… Worked perfectly! Thanks a lot for the great tutorial!

  52. Ganesh Bhat

    Running the below command on Windows installation of docker gives the below error.

    docker -H tcp:// images
    error during connect: Get dial tcp connectex: No connection could be made because the target machine actively refused it.

  53. Alexander

    How to “reload your environment” so that bash saw the changes?

  54. wyysa

    My God, It took me two days to run it, but it didn’t work until I read your article and I knew it was impossible, so, I needed another way

Leave a Reply