I am working on Windows and I need to use libraries, which are availible only with Linux (TensorFlow,Caffe). I would like to run the software on Docker. I cannot understand the docker mechanism clearly, so I am completly lost, when its up to my problem. What should I do and how should it work?
问题:
回答1:
Edit:
About Windows Docker hosting capabilities (container on a Windows host):
- Windows 10 offers Docker host capabilities, but only based on Hyper-V, i.e. by means of Linux-like VMs.
- Windows 2016 offers native Docker host capabilities (thanks to @friism to point this out below).
About Windows Docker container capabilities (Windows in a Container):
- Windocks offers .Net and SQL Server support within Containers (thanks for @paul).
- On Windows 2016, a windowsservercore base Docker image allows you to run Windows services, see this simple example.
- On a Windows 10 & Hyper-V, the nanoserver base Docker image allows you to run Windows commands (see here a helloworld PowerShell example). Requires the Windows version of the Docker daemon and will not work on Linux Docker hosts, see here.
Original Answer:
Bad news first: Docker is not (not fully correct, see edit above) supported on Windows hosts natively (okay, that depends on how you define "natively". I mean, Docker always needs a Linux-like Docker host, see the good news below).
The good news is that Docker can be used on Windows by running Docker containers on a Docker host, which is running as a virtual Linux machine on Windows e.g. on VirtualBox, VMware or, nowadays officially preferred on Windows 10 Professional: on Hyper-V.
The best news for you is: since Docker containers are running on Linux-like hosts and are offering a Linux environment within a container, you can install any Linux software within the container the same way as you would do on a native Linux machine. Say, you start a Docker container with interactive terminal from an Ubuntu Docker image, by issuing the command
docker run -it ubuntu bash
you can run any apt-get
command in this container.
Note, that the data you have changed in a container are not meant to be persistent. Once you have installed the SW in the container, you may want to preserve your work by building a new Docker image from the new container using docker commit commands. An advanced and automated way to create such images is to add your tested installation commands as RUN directives in a Dockerfile and to build the image from it without the need to manually run an interactive container and manually add the software.
回答2:
Windows 10 Anniversary edition includes a Linux subsystem (Ubuntu-based), what is commonly called Bash on Windows
. It's not just Bash, it's a translation layer that allows you to run user-mode applications on Windows itself, and the Ubuntu binaries on top. You can use it to run user-mode applications.
Scott Hanselman shows how you can use TensorFlow this way using exactly the same command you would on a Linux machine in Playing With Tensor Flow On Windows. Copying from Scott's post:
$ sudo apt-get install python-pip python-dev
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl
will install TensorFlow and
$ cd tensorflow/models/image/mnist
$ python convolutional.py
will start executing the MNIST demo
The only annoyance is that it's Ubuntu 14.04.5 LTS, not the latest 16.04