mardi 13 décembre 2016

[Fiction] Learning Docker watching ... WestWorld

Warning: this does contain potential spoilers, so I recommend you to watch this great show and then come back.

Synopsis

You finally to go the most famous attraction in the world, this place where you will find your inner self. You finally had the needed ressources to visit WhaleWorld.
Welcome to the land of your Dreams where you are the Hero, do whatever you want and never be harmed ... or is it?

Episode 1: Catch the train

You're arriving in WhaleWorld and at the first glance everything seems normal: Applications are discussing with the Databases and answering the Guests as they should be. These hosts seem familiar, like VMs, but at the same time very different. These hosts seem "lighter", less overhead, and still with OS capabilities. How can this be?
The logical next step is to meet and learn more about these Hosts.
source: http://www.rightscale.com/blog/sites/default/files/docker-containers-vms.png

Episode 2: Meet the Hosts

Before you came to WhaleWorld, you heard the consistant rumors that only Linux folks were welcome.
But you, the "Windows Renegade" wanted to come and see this world and more specially the TownHall where the Hosts were registered. That's where you saw Doloresoft! You could not believe your eyes, this World already had such technology?!
Now you truly want to know more about the technology behind, because while their Heart was different, they seemed to be created in the same way.
source: http://acom.azurecomcdn.net/80C57D/blogmedia/blogmedia/2014/10/15/DockerWithWindowsSrvAndLinux_thumb.png

Episode 3: Build your own Host

Doloresoft, you cannot think about anything else, but how? How did the creators build it? While having a drink in the town's bar "DockerCon", you heard about a certain tool called "Dockerfile".
According to the discussions, you could create the skeleton of your Host in re-usable manner.
You already know that try and fail are part of any creation process and creating your first Host will not be any different.
source: http://image.slidesharecdn.com/dockerizing-aspnet-4x-windows-seattlecodecamp-160913043955/95/docker-all-the-things-aspnet-4x-and-windows-server-containers-16-638.jpg?cb=1473741684

Episode 4: Compose your own Storyline

Some time passed, and you now know how to create your own Host, feeling almost like the creator: Arnolmonstre.
However you start feeling limited compared to all the other Hosts in WhaleWorld. It seems that some Hosts are acting in a group, almost as if they were only one entity, working together in a common storyline.
If only you could Compose such storylines, then you could maybe add your own to WhaleWorld!
source: https://msdnshared.blob.core.windows.net/media/2016/10/ComposeFile.png

Episode 5: Overwhelmed? Call the Swarm!

The long road to get your own storyline is finally ending, but in the first day of suggesting it to the other guests you start feeling the pressure that actually the demand is way bigger than what your Hosts can handle.
If only you could create twins of your Hosts, and not only few, you need a Swarm! A Zerg like Swarm!
source: https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0yBSw2tyyqNAcmeWdueMzQcUIB7udy96X6NigV0L-PU7WyRgnOcY5No_l_3ps34L09OACfrBkbvfkYCU9jegsu6_415N4QmT3SbWoKari8fKUEZ3z9u1JbiG1SVy9wRvHABAj-lxdYX4/s1600/es-swarm-1.png

To be continued ...

lundi 7 novembre 2016

WSL Docker: Mounts behaviour

Introduction

WSL and Docker client have been now around for quite some time. Crazy people like me, even got them working together.
Of course, the initial thought was to install the Docker daemon on WSL, and we very rapidly got to the conclusion that it was not possible right now.

Now, while doing some tests, I came to one situation that might be interesting/helpful to know: when mounting a path from WSL, actually what is being mounted is actually ... something else!

The Facts

Before I go into the demo, please remember "how" everything is being connected together.

Components:

  1. Docker daemon running inside MobyLinuxVM on Hyper-V
  2. Docker client running inside WSL on pProcess (port 2375 exported)
  3. Docker Proxy (1.12 beta) that actually manages the communication from the Docker Clients to the Docker Daemon(s)

Demo:

Ok, enough with the theory, here is the demo. I split it in 2 distinct containers.

Phase 1 - First Container


  1. [WSL] Create a directory and a file inside it
  2. [WSL] Run a new Ubuntu container with the directory mounted
  3. [Docker] List the content of the directory mounted
  4. [Docker] Create a file inside the mounted directory
  5. [Docker] Exit the container
Result: not really what we wanted to achieve. Let's jump into the next Phase

Phase 2 - Second Container


  1. [WSL] Run a new Ubuntu container with the directory mounted
  2. [Docker] List the content of the directory mounted
  3. [Docker] Exit the container
Result: surprise, actually the file created inside the first container is the one we see and resides inside the MobyLinuxVM

Conclusion

Actually, the really intelligent persons working @Docker, blocked the capabilities of the mounts (of course, SECURITY FIRST!)
So, if someone too curious tries to mount a system FS (i.e. root for fun), then here is what can be seen:

Hopefully, in the future, even WSL mounts will be possible.

>>> Nunix out <<<


vendredi 28 octobre 2016

Docker for Windows: 2 daemons enter in a bar

Disclamer

This! is! Very! Higly! Experimental!
So friendly advice, test it somewhere you don't break anything. You're warned, don't blame the Swiss Guy after that!

The goal

Since Docker 1.12 (beta) shipped and the incredible feature of swapping daemons appeared, I had the idea that actually both could run in parallel.
I simply didn't knew "how" exactly it could be done, as Docker implemented a proxy that stops and starts either daemon you decide to switch to (read Stefan's blog, really more detailed than my 2 Swiss Francs explanation :)

Still, the Linux daemon being containerized in Hyper-V MobyLinuxVM, and the Windows Containers relying on the "Containers" feature (which by the way comes with Hyper-V isolation by default), there should be a way to run them at the same time, right?

The setup

Thanks to the Windows Subsystem for Linux (WSL), my goal was to use Bash for "Linux Docker" containers and Powershell for "Windows Docker" containers on the same machine.
So in order to have it running correctly, I needed to had the following components:
  • Windows 10 with Anniversary Update (I'm currently an Insider within the Slow Ring realm)
  • WSL + Containers + Hyper-V features enabled
  • Docker for Windows (beta channel)
  • Docker client on WSL (see my blogpost or Google Search)

Daemons are coming

Feeling ready? then let's mix it up as Docker puts it nicely, "Happy Hacking":

  1. Via the Docker Tray, switch to Linux Containers (if not already done).
    Or, for the Terminal lovers, run:
    C:\Program Files\Docker\Docker\DockerCli -SwitchDaemon
  2. From Bash (or Powershell), set the DOCKER_HOST variable and check the version:
    $ docker version
  3. [Linux Milestone]Good, our "Linux environment" is up and running. Now time to address the Windows one.
  4. Open a first Powershell window as Administrator !!! MANDATORY !!!
  5. Normally, the docker path should be in your $env:PATH already. So to start a new docker daemon, run (see notes section for more details):
    dockerd.exe -H npipe:////./pipe/docker_engine_windows -H 0.0.0.0:3625
  6. From another Powershell window, set the DOCKER_HOST variable to the new NPIPE and Port and check the version:
  7. [Windows Milestone]Good, our "Windows environment" is up and running in parallel of the Linux one:

Notes

  • I did not make anything permanent as you can see. This only served as a test and is highly experimental. I don't have an in-depth vision of the mechanics behind docker, and running two daemons could bring pain and suffering to your existing implementations.
  • My next attempt will be to actually start the Windows Docker daemon with TLS enabled. This is crucial if, not like me, you are running your Docker instances in the Cloud and not in your own laptop (Surface Pro 4 in my case)
    Once again, THANK YOU Stefan Scherer's Blog. If you pass by the French side of Switzerland, come say hi :)
  • First "joke", concerning the port chosen: I took a picture of a Nokia 3210 and checked how to write Docker (362537), as it was a bit too high, I only took the "DOCK" portion.
  • Second "joke", I do have another blog post unpublished with the "other way" on how to actually connect to the Docker host running on the MobyLinuxVM.
    It's unpublished as I could not figure it out on how to connect directly to the Docker port on the VM.
    So if anyone tried and succeed, please let me know.

dimanche 19 juin 2016

Docker CLI on WSL for Docker beta on Win10

Introduction

For this second post, I will continue the work of getting WSL to feel even more "home".
As stated before, I have "crazy" ideas and 2 of them are:
  1. Get a "Docker Ocean" where both MSWhales and NixWhales can swim freely ;) -> simply means that I could pull both kernels images and run them on Win10 (if possible), while choosing the Linux Docker CLI instead of Powershell. Yes, just because I can (and because that's this blog topic).
  2. I have the chance to have a Pluralsight account (thanks Boss) and I would like to edit files with the great VSCode, while running the backend services on WSL. My current test is Angular2 (but more to come eventually on a future blog post).

Goal of this blog post

Nothing fancy here, just want to show (if you don't know it by know) how easy it is to interact between WSL and the Win10 "hosting" it.
Also, I'm trying to put all the building blocks together in order to achieve my crazy idea 1.

Prerequisites

Based on the Goal described above, there's only 2 mandatory prerequisites and 1 optional:

Docker installation on WSL

Be ready as this one will be the most difficult task of this blog post:
 $ curl -sSL https://get.docker.com/ | sudo sh 

Ok, it will indeed "install" Docker, however the Daemon will fail to start:

Still, the Docker CLI is installed and working fine. And, as expected, only  $ docker version  is returning a result:

Just for a comparison, here is the result of  > docker version  from Powershell:

Make it work all together

Before you can finally start playing with Docker, there's one last important setting to configure in order to be able to communicate with the running Docker Beta daemon:
 $ export DOCKER_HOST=tcp://:2375 

And now you can choose either Powershell or "Bash on Ubuntu on Windows" (yes, doing it on purpose until a better name comes :) to manage Docker containers on Win10:

Final thoughts

The more I "play" with Win10 and WSL, the more it confirms my impression: Win10 is all about possibilities and choices.
The "how can I" replaced the "why can't I" ... 

Big props again to all the persons involved in or outside Microsoft.

Darth Nunix


dimanche 12 juin 2016

Ubuntu 16.04 on Ubuntu on Windows (WSL)

Disclaimer

First thing first, I'm a quite average technical person. I know a bit of everything without being specialized in anything.
This actually sometimes work in my favor, as I do not fear to test "crazy" things that are, normally, not meant to go together.

Prerequisites

Windows side

  1. Be part of Windows Insider (fast ring preferred)
  2. Have the latest Windows 10 Insider release installed
  3. Install Windows Subsystem for Linux (WSL) feature

Linux side

  1. Get the Repositories list for Ubuntu 16.04
  2. Make a backup of the current sources.list
     $ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak 
    • For information, here is the default sources.list
  3. Update the Repositories list with the list for Ubuntu 16.04

Finally the upgrade

As for any upgrade, once everything has been prepared well, the upgrade itself will (normally) only be a question of install wait.
I will, on purpose, be verbose with the commands, and if you know a bit of Linux commands, I'm sure you can do it in one line.
NOTE: as I'm posting this blog after I've done the upgrade, I have unfortunatly no printscreens to share of the upgrade itself.
  1. Update the list of packages available after the "sources.list" has been updated
     $ sudo apt-get update 
  2. Upgrade the distribution
     $ sudo apt-get dist-upgrade 
    • Type "Y" to install all the required Packages
  3. IMPORTANT: at some point in the install, you will be asked to update the rcS.d files. As the WSL has some "magic" in it, I choose to keep it as is. Really not sure if this would have an incidence or not.
    • Therefore, type "N" or just enter as it is the default when prompted for the update.
And that's actually all. It took my old pc (elitebook 8470p 4g RAM) about 20 minutes for the upgrade.
In order to be ensure everything is properly applied, I rebooted windows, as I do not know (yet) how I can reboot the WSL instance (read pico-process) itself.

I confirmed in 2 ways that ubuntu was correctly installed:

And that's all for now. My next blog post will be about another crazy idea that I also put on twitter already: have Docker runtime in WSL to manage Docker Beta for Windows.

Hopefully, this (first) blog post will help or at least give ideas for one person at least.

Darth Nunix