Can you run Docker natively on the new Windows 10 (Ubuntu) bash userspace?

My understanding was that the primary limitation of running docker on other OSs was the Linux Network containers that made it possible. (Certainly for Macs).

Recently Microsoft announced a beta of a Ubuntu linux user mode running natively on Windows 10. This can run binaries compiled in ELF format on Windows (unlike cygwin which requires a compilation.)

My question is: Can you run Docker natively on the new Windows 10 (Ubuntu) bash userspace?

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

As of right now (April 2016) the answer is:

We do not know yet (but probably not).

The facts

  • Windows 10 can now run a variety of Linux programs (among them the Bash shell and various text utilities). These are not ports (i.e. recompiled versions, like for example in Cygwin), they are the same ELF binaries that run on a typical Linux system. In this case, they were taken from Ubuntu.
  • To make this possible, Windows 10 was modified to accept Linux System calls (syscalls), and to be able to load and run ELF binaries (comment by Scott Hanselman). This means unmodified Linux executables can be run, they will load their unmodified shared libraries as required, and Windows will run them as Windows processes.
  • Whenever such a Linux program wants to interact with the kernel, it issues a system call (or lets a library do it). This is (presumably) the only difference to running on Linux: When running on Linux, the Linux kernel handles theses calls; on Windows 10, the Windows 10 kernel does it instead.

The speculation

So the question is whether the syscalls that Docker needs (for chroot and namespaces, among other things) were implemented or not. The answer is to that is likely "no". Docker requires fairly sophisticated (and Linux-specific) functionality for process and resource management, and process isolation. While it is probably possible to replicate all this on Windows, it would be a lot of work, and since the goal of this Windows feature seems to be running Linux userspace programs, it seems unlikely they did all the work (and kept it secret).

However, there is no definitive information either way,as far as I can tell.

Existing Docker ports

Of course, if Microsoft decides they want Docker support in Windows 10, they will probably able to offer it. There is some precedent for porting Docker to a different kernel:

  • There is a Docker port for FreeBSD. It is labeled "experimental", but in seems to work in principle. It can use unmodified Docker containers from the Docker repository, meaning it actually provides a Linux-like host environment for the images.
  • There is a project underway for porting Docker to Windows (specifically, Windows Server 2016) - see this Docker blog entry from August 2015. However, unlike the FreBSD port above, this will be a port that allows Docker to run Windows images on Windows, not Linux images on Windows. Thanks to Rоry McCune for pointing this out.

No, this is not possible.

Docker needs multiple things in order to run containers:

  • chroot
  • Namespaces for:
    • PID
    • Users
    • Network
    • Mounts
    • UTS
    • IPC

These are all kernel features that are implemented in Linux. Unfortunately, most of them do not have a similar feature in Windows to use as a replacement (nor in the Linux Subsystem that Microsoft implemented in the Windows kernel). All these need to be provided by the OS.

The first insider preview was released yesterday. I've attempted to install docker but it fails with the following:

So it would appear, that for the first preview it does not currently work. However as many people have speculated, it may work in a future release.

As of the Creator Update (released publicly on June 13, 2017) you can run native Windows executable directly in WSL. This means if you've already installed Docker for Windows you can simply invoke the docker binaries installed under C:\Program Files. Since they end in .exe the easiest option is to create aliases. Something like the following in your .bashrc should work:

DOCKER_BIN='/mnt/c/Program Files/Docker/Docker/resources/bin'
for f in "$DOCKER_BIN"/*; do
  alias "$(basename "$f" | sed 's/.exe$//')"'="'"$f"'"'
done

This creates aliases for all the files in the DOCKER_BIN directory:

$ type docker
docker is aliased to `"/mnt/c/Program Files/Docker/Docker/resources/bin/docker.exe"'

$ docker --version
Docker version 17.03.1-ce, build c6d412e

One caveat: you'll get an error message like "Unable to translate current working directory" if run from a Linux directory. Just cd into a Windows directory (e.g. /mnt/c/Users/YourUsername) and you should be good.

Once Docker 1.12 is released and the Linux Docker client is separated, you should be able to run the docker client in Windows 10 bash.

This may not sound like much given you have a Docker Windows client but it's useful if you have Linux toolchains that include docker for it's client-side functionality.

In Windows 10 Version 1607 Build 1493.10 you can successfully install it on Ubuntu Bash, but it doesn't work :(

A simple "docker version" will tell you:

Client version: 1.6.2
Client API version: 1.18
Go version (client): go1.2.1
Git commit (client): 7c8fca2
OS/Arch (client): linux/amd64
FATA[0000] Get http:///var/run/docker.sock/v1.18/version: dial unix /var/run/docker.sock: setsockopt: invalid argument. Are you trying to connect to a TLS-enabled daemon without TLS?

If you then run "sudo docker -d" you get the following error:

FATA[0000] ERROR: You are running Linux kernel version 3.4.0+, which is unsupported for running Docker. Please upgrade your kernel to 3.8+.

So this is definitely a stopper from the bash side.

Nevertheless, you can install Docker for Windows and it works like a charm, you can obviously deploy Linux Servers and everything you need.

> docker version
Client:
 Version:      1.12.0
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   8eab29e
 Built:        Thu Jul 28 21:15:28 2016
 OS/Arch:      windows/amd64

Server:
 Version:      1.12.0
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   8eab29e
 Built:        Thu Jul 28 21:15:28 2016
 OS/Arch:      linux/amd64

As of September 2016, No.

All current implementations of Docker on Windows use virtualisation, Docker 1.12 uses a hypervisor in Windows -thus removing the advantage of containerisation over virtualisation.

Docker needs more than just using Linux systems calls.

It needs process control groups (cgroups), a stackable filesystem (aufs), plus other Linux-based systems outside the kernel.

Neither cgroups nor aufs are natively in the Windows 10 kernel.

There is an implementation of Windows Server 2016 here: https://msdn.microsoft.com/en-gb/virtualization/windowscontainers/quick_start/quick_start_windows_server ..but this will only run some Windows services, e.g. IIS, and not Ubuntu

Docker does not currently work in the current build (14316) - assuming you can get it installed.

root@localhost:~# docker --help
runtime: address space conflict: map(0x7ff5ddbb0000) = 0x7ff5ffd20000
fatal error: runtime: address space conflict

From: https://blog.docker.com/2016/07/docker-for-mac-and-windows-production-ready/

Faster and more reliable – native development environment using
hypervisors built into each operating system. (No more VirtualBox!)

It’s not “just” a bash userspace. It’s a real, fairly complete Linux userspace, but without X Windows i.e. text only. Saying “bash” communicates the text-only limitation quite well…

indeed that’s the purpose of the Windows native docker. The nature of containerisation is that you can’t run systems with other kernels, without adding in some virtualisation or (possibly) this new subsystem that Microsoft are developing

I think it won’t be clear until they release this (AFAIK it’s not even available to windows insiders as yet) however it’s worth noting that Microsoft and Docker are working on bringing Docker to Windows natively, to be released alongside Windows server 2016

@RоryMcCune: Interesting. However, according to this Docker blog entry from August 2015, this will be a port that allows Docker to run Windows images on Windows, not Linux images on Windows.

For a GNU system to run on a Windows kernel is certainly possible. It would be a LOT of work for a very lateral shift in quality. I would be surprised if it happened, or if people adopted it.

Did I miss something? Did this actually get distributed? At the moment I only know of it as vaporware.

Related: docker error: /var/run/docker.sock: no such file or directory.

Is it possible to run windows docker image on ubuntu aws instance ? or is there some alternative ? …root@ip-172-31-22-20:~/docker/windows# docker pull microsoft/nanoserver
Using default tag: latest
latest: Pulling from microsoft/nanoserver
bce2fbc256ea: Pulling fs layer
4806a44e00a0: Pulling fs layer
image operating system “windows” cannot be used on this platform
root@ip-172-31-22-20:~/docker/windows#