Category Archives: Linux

Install Docker on Windows / WSL Ubuntu

We will run the Docker Engine on Windows 10, and connect to it from WSL Bash as WSL does not fully support Docker yet.

OS requirements

To install Docker CE, you need the 64-bit version of one of these Ubuntu versions:

  • Artful 17.10 (Docker CE 17.11 Edge only)
  • Zesty 17.04
  • Xenial 16.04 (LTS)
  • Trusty 14.04 (LTS)

Uninstall old versions

Older versions of Docker were called docker or docker-engine. If these are installed, uninstall them. The Docker CE package is now called docker-ce.

$ sudo apt-get remove docker docker-engine

Docker CE now uses the overlay2 storage driver by default, and it is recommended that you use it instead of aufs.

Install using the Docker repository


  1. Update the apt package index:
$ sudo apt-get update

2. Install packages to allow apt to use a repository over HTTPS:

$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \

3. Add Docker’s official GPG key:

$ curl -fsSL | sudo apt-key add –

Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint.

$ sudo apt-key fingerprint 0EBFCD88

pub   4096R/0EBFCD88 2017-02-22
      Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid                  Docker Release (CE deb) <>
sub   4096R/F273FCD8 2017-02-22

4. Use the following command to set up the stable repository. You always need the stable repository, even if you want to install builds from the edge or test repositories as well. To add the edge or test repository, add the word edge or test (or both) after the word stable in the commands below.

Note: The lsb_release -cs sub-command below returns the name of your Ubuntu distribution, such as xenial. Sometimes, in a distribution like Linux Mint, you might have to change $(lsb_release -cs) to your parent Ubuntu distribution. For example, if you are using Linux Mint Rafaela, you could use trusty.


$ sudo add-apt-repository \
   "deb [arch=amd64] \
   $(lsb_release -cs) \


  1. Update the apt package index.
    $ sudo apt-get update

2. Install the latest version of Docker CE, or go to the next step to install a specific version. Any existing installation of Docker is replaced.

$ sudo apt-get install docker-ce

4. Verify that Docker CE is installed correctly by running the hello-world image.

$ sudo docker run hello-world

This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits. Got an error:

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.

You cannot run the Linux Docker daemon in WSL. The Linux kernel emulation done by WSL doesn’t have good enough fidelity to support the Docker daemon. The Docker CLI works fine.


Install Docker for Windows

Download Docker for Windows: Stable channel

The current version of Docker for Windows runs on 64bit Windows 10 Pro, Enterprise and Education (1607 Anniversary Update, Build 14393 or later).

The Docker for Windows installer will enable Hyper-V for you, if needed, and restart your machine. After Hyper-V is enabled, VirtualBox will no longer work, but any VirtualBox VM images will remain. You can check in Windows Task manager->CPU if virtualization is enabled.

Double-click Docker for Windows Installer.exe to run the installer.

Docker will not start automatically. To start it, search for Docker, select the app in the search results, and click it (or hit Return). When the whale in the status bar stays steady, Docker is up-and-running, and accessible from any terminal window.

PS C:\Users\>docker run hello-world
Unable to find image ‘hello-world:latest’ locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the “hello-world” image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Congratulations! You are up and running with Docker for Windows. Run some docker commands in WSL ubuntu:

root@:~# /mnt/c/Program\ Files/Docker/Docker/resources/bin/docker.exe images
Unable to translate current working directory. Using C:\Users\DOCUME~1\MOBAXT~1\home
hello-world latest f2a91732366c 3 weeks ago 1.85kB


To not have to type entire path to docker.exe add these lines to /root/.bashrc   in WSL ubuntu and relogin:

PATH=”$PATH:/mnt/c/Program\ Files/Docker/Docker/resources/bin”

root@:~# docker.exe images
Unable to translate current working directory. Using C:\Users\DOCUME~1\MOBAXT~1\home
hello-world latest f2a91732366c 3 weeks ago 1.85kB

To avoid this warning message create a directory under /mnt/c/Users/userid/docker and cd to that directory and run docker commands:

root@:/mnt/c/Users/userid/docker# docker.exe info

Containers: 3
Running: 0
Paused: 0
Stopped: 3
Images: 1
Server Version: 17.09.1-ce









Ansible script examples

EXAMPLE: Restart NTP daemon in Linux

First create the playbook pbntprestart.yml as below and run using this command. The cdhservers is where you define all your hostnames.

$ ansible-playbook pbntprestart.yml -u root -k

The content of pbntprestart.yml  is below:

$ cat pbntprestart.yml

– hosts: cdhservers

shell: service ntpd restart
register: out1
– debug: var=out1.stdout_lines

shell: ntpstat
register: out2
– debug: var=out2.stdout_lines

shell: service ntpd status
register: out3
– debug: var=out3.stdout_lines


EXAMPLE: Run step by step each ansible task

ansible-playbook pbtest.yml -u userid -k –step


EXAMPLE: Check linux system basic status

$ cat pbchkuptime.yml

– hosts: cdhservers
shell: uname -a;uptime;free -h;df -h
register: out1
– debug: var=out1.stdout_lines