38

I was reading a nice question about docker - answer has overview of docker implementation details. I was wondering if anything like this is possible to do on Windows platform.

  • Do Windows alternatives for Docker exist?
  • Is it theoretically possible to use other (Windows based) components to build it?

Update1:

Update2::

For info how to install docker on windows (unrelated) - official docs has great instructions how to set up the environment by using boot2docker VM.

Community
  • 1
  • 1
Jiri
  • 16,425
  • 6
  • 52
  • 68

9 Answers9

23

You can run docker in a virtual machine.


New Update

Vagrant has now integrated docker support. It can be used as provider or as provisioner. Here are some useful links.

Feature Preview: Docker-Based Development Environments

Vagrant Docs: Docker Provisioner

Vagrant Docs: Docker Provider


Old Update

As seanf pointed out in a comment below, Vagrant support was dropped. Instead they point to boot2docker:

boot2docker is a lightweight Linux distribution based on Tiny Core Linux made specifically to run Docker containers. It runs completely from RAM, weighs ~24MB and boots in ~5s (YMMV).

Old answer

The official docker documentation contains a small guide to install docker inside a Vagrant box. Vagrant is a great vm management wrapper. The guide is for Mac/Linux, but you get the idea to do the same in Windows:

http://docs.docker.io/en/latest/installation/vagrant/

This way you can share docker images across multiple systems with different operating systems.

Alp
  • 29,274
  • 27
  • 120
  • 198
  • 3
    Vagrant installation has been retired as of https://github.com/dotcloud/docker/pull/4281, with the required `Vagrantfile` removed from git and the instructions above removed. The Windows Vagrant instructions no longer work, and will probably be gone soon. The new instructions use boot2docker, but **without** persistent storage on Windows. However, the old Vagrant guide for Windows is here: https://github.com/unclejack/docker/blob/4f20538f/docs/sources/installation/windows.rst For now, it still works, but you need to check out an earlier commit: `git checkout 4f20538f` before `vagrant up`. – seanf Feb 26 '14 at 12:44
  • 1
    My experience with this is that the lack of persistent storage makes the new VM a bit less useful since you can't pull images of any meaningful size. I was able to get the new approach working, but it took some hacking about (could be that it is all documented somewhere, but I couldn't find it). – sfitts Mar 19 '14 at 00:07
  • what would be the way to deploy containers with persistence? – Thomas May 24 '14 at 17:18
  • IMHO running Docker in a VM completely defeats the purpose of Docker, as [it enjoys the resource isolation and allocation benefits of VMs but is much more portable and efficient](http://www.docker.com/whatisdocker/). – sschuberth Jul 02 '14 at 07:09
  • @sschuberth you are right, but the docker provider does exactly that, and more: http://docs.vagrantup.com/v2/docker/basics.html – Alp Jul 02 '14 at 10:18
  • 1
    As another update, [since recently](https://blog.docker.com/2016/03/docker-for-mac-windows-beta/) there's a Docker for Windows version (and a Mac OS X version) in private beta that runs without VirtualBox in favor of using Hyper-V. – sschuberth May 16 '16 at 18:48
  • As far as I know if you want to use VirtualBox, you have to disable Hyper-V, so if you use VirtualBox for anything, you have to stick with it. – Jiri Mar 15 '17 at 14:53
8

If you're just searching for a way to deploy a pre-packaged set of applications in some sort of container for Windows, with registry and file access being virtualized but without using a full-blown virtual machine image, these (commercial) sandbox-like applications might be worth looking at:

Edit: There's a new kid on the block, Spoon supports containers for Windows, and it actually looks very promising.

sschuberth
  • 28,386
  • 6
  • 101
  • 146
6

I have found that at least file system related functionality has Windows (7,8) already in place. One can use VHD files (virtual disks) for handling "images" concept in Docker. These image are used for virtual machine but can be created/attached/used directly by Windows too:

diskpart
DISKPART> create vdisk file=c:\base-image.vhd maximum=200 type=expandable

New image can be layered on top of base image:

DISKPART> create vdisk file=c:\image-2.vhd parent=c:\base-image.vhd

See more information about managing virtual disks.

Unfortunately, process lightweight isolation/sandboxing is probably not possible (at least not simple), although some methods do exists (http://www.sandboxie.com/, Native Client in Google Chrome ...)

Jiri
  • 16,425
  • 6
  • 52
  • 68
3

Microsoft is working on their own Hyper-V Container that is similar to Docker - Azure also supports the Docker infrastructure.

That aside, it's hard to give precise alternatives but on the Windows side we've had App-V for quite a long time which virtualises and sand-boxes applications so they can be run or streamed without being actually installed on a specific system. I've never meddled with it but it seems to be able to run as a standalone client without any need of the intricate server infrastructure usually involved for anything Microsoft.

From another perspective the disk image format used by Windows (VHD) supports standard differencing so you can easily run many virtual machines from a single read-only OS image where each virtual machine have a tiny write image to handle the differences. These are still fullblown virtual machines though.

Oskar Duveborn
  • 2,189
  • 16
  • 20
2

I currently don't know of any way to do the same thing on native windows as of right now.

I don't think the windows kernel was built for this sort of thing, so in order for it to be supported Microsoft would have to add the capabilities to the windows kernel. If I'm wrong, someone please correct me.

The most common way for people to do something like this is to use a VM in windows that runs a Linux based OS, and running everything inside of that. You could also do the same thing using FreeBSD (Jails), and Solaris (zones), if that is more your cup of tea. But Docker currently doesn't support FreeBSD or Solaris, so you will need to use the native tools for those.

Ken Cochrane
  • 75,357
  • 9
  • 52
  • 60
  • Aren't Jails and Zones exactly the same as Docker, except for different OS? – Didier A. Jan 28 '14 at 01:25
  • @didibus FreeBSD Jails and Solaris Zones are similar to LXC. Docker only support LXC for now, but long term it could add support to also manage Jails and Zones as well. – Ken Cochrane Feb 03 '14 at 14:04
2

Starting in june 2016, Docker can be run on Microsoft's Hyper-V virtualization on Windows 10 hosts. This is now the preferred and "official" way to run Docker on Windows.

https://docs.docker.com/engine/installation/windows/

Hyper-V is a Type-1-Hypervisor, meaning docker will run one layer closer to the host hardware and perform significantly faster than boot2docker (which uses VirtualBox, a Type-2-Hypervisor, running inside the host OS).

The performance benefit for docker has a downside too: Enabling Hyper-V will prevent hardware virtualization features for Type-2-Hypervisors, therefore existing VirtualBox images can not be used with VTx, and you might want to consider moving other virtualized OSes to Hyper-V as well.

Windows 7-8.1 hosts can still use boot2docker to run Docker containers, but the main development focus for Docker on Windows is the "new" Hyper-V-Docker.

Leon Adler
  • 2,993
  • 1
  • 29
  • 42
1

Hyper-V is only on Windows Pro. Install it for £110.

Or simply install Vagrant, install VirtualBox, install GIT bash, then from your GIT bash terminal.

git clone git@github.com:danday74/vagrant-docker-skelly.git
cd vagrant-docker-skelly
vagrant up # takes approx 5 mins to create VM
vagrant ssh
docker -v
docker-compose -v

The Vagrantfile shows that:

1 - this is a Xenial VM with docker and compose installed on it

2 - Ports mapped from Host to the VM are 9900-9920

3 - The shared folder is shared from host to VM

Tweak this as desired.

halfer
  • 19,824
  • 17
  • 99
  • 186
danday74
  • 52,471
  • 49
  • 232
  • 283
0

I got tired fighting with a maven docker plugin so I figured I would be able to fake it. This is how:

Using boot2docker and the following bat file makes it look like you're running docker natively. Place it on your path.

@set SSH="C:\Program Files (x86)\Git\bin\ssh.exe"
@set RUN_REMOTE='docker %*'
@ %SSH% -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -p 2022 -i %HOMEPATH%/.ssh/id_boot2docker -tt docker@localhost %RUN_REMOTE%

The ssh.exe comes from the msys-git package which is bundled with boot2docker. I'm pretty sure this solution have quite a few caveats, but it works pretty good for me. Place this file on your path and bob's yer uncle.

Markus T
  • 1,554
  • 13
  • 14