You can use Docker Desktop for Windows as the engine and Docker for Linux as the client in WSL on Ubuntu / Debian on Windows. Connect them via TCP.
Install Docker Desktop for Windows: https://hub.docker.com/editions/community/docker-ce-desktop-windows
If you want to use Windows Containers instead of Linux Containers both type containers can be managed by the Linux docker client in the bash userspace.
Since version 17.03.1-ce-win12 (12058) you must check Expose daemon on tcp://localhost:2375 without TLS to allow the Linux Docker client to continue communicating with the Windows Docker daemon by TCP
Follow these steps:
cd
wget https://download.docker.com/linux/static/stable/`uname -m`/docker-19.03.1.tgz
tar -xzvf docker-*.tgz
cd docker
./docker -H tcp://0.0.0.0:2375 ps
or
env DOCKER_HOST=tcp://0.0.0.0:2375 ./docker ps
To make it permanent:
mkdir ~/bin
mv ~/docker/docker ~/bin
Add the corresponding variables to .bashrc
export DOCKER_HOST=tcp://0.0.0.0:2375
export PATH=$PATH:~/bin
Of course, you can install docker-compose
sudo -i
curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
Or using python pip
sudo apt-get install python-pip bash-completion
sudo pip install docker-compose
And Bash completion. The best part:
sudo -i
apt-get install bash-completion
curl -L https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker > /etc/bash_completion.d/docker
curl -L https://raw.githubusercontent.com/docker/compose/$(docker-compose version --short)/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose
I've tested it using the 2.1.0.1 (37199) version of Docker Desktop using Hyper-V:
$ docker version
Client: Docker Engine - Community
Version: 19.03.1
API version: 1.40
Go version: go1.12.5
Git commit: 74b1e89e8a
Built: Thu Jul 25 21:17:37 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.1
API version: 1.40 (minimum version 1.12)
Go version: go1.12.5
Git commit: 74b1e89
Built: Thu Jul 25 21:17:52 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.2.6
GitCommit: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
runc:
Version: 1.0.0-rc8
GitCommit: 425e105d5a03fabd737a126ad93d62a9eeede87f
docker-init:
Version: 0.18.0
GitCommit: fec3683
Look both client and server say **OS/Arch: linux/amd64**
Volumes
Take care when adding volumes. The path C:\dir
will be visible as /mnt/c/dir
on WSL and as /c/dir/
by docker engine. You can overcome it permanently:
sudo bash -c "echo -e '[automount] \nroot = /'>/etc/wsl.conf"
You must exit and reload WSL after making the change to wsl.conf so that WSL reads in your changes on launch.
UPDATE
from: What’s new for the Command Line in Windows 10 version 1803
Unix Sockets
Unix Sockets weren't supported on Windows, and now they are! You can also communicate over Unix sockets between Windows and WSL. One of the great things about this is it enables WSL to run the Linux Docker Client to interact with the Docker Daemon running on Windows.
UPDATE
This script and the use of Unix Sockets was included in Pengwin's pengwin-setup.
Regards