Installing Docker on Windows

I recently set up Docker on both Windows 10 and Windows 7.  In both cases, it was a slightly bumpy experience, so I am recording the steps I followed here.

Windows 10

Machine Specifications
  • 64-bit Windows 10
  • VT-X/AMD-v support enabled in the BIOS
  • Hyper-V installed
  • Latest version of VirtualBox (version 5.0.16 at the time of this writing) installed
Process

STEP 1

Download and install Docker Toolbox.  This is straightforward, and detailed instructions for doing this are available online).

STEP 2

Docker on Windows requires VirtualBox in order to run a lightweight Linux virtual machine.  VirtualBox and the Windows Hyper-V technology are mutually exclusive technologies; you cannot use both at the same time.  Therefore, If Hyper-V is installed and enabled on your machine, you should disable it by following the directions found here.

STEP 3

The Docker startup script checks for the presence of Hyper-V, and halts if it is found.  It does NOT check the enabled/disabled state of Hyper-V.  So, if Hyper-V is installed on your computer, add a parameter to the Docker startup script to avoid the Hyper-V check.

  1. Locate the file C:\Program Files\Docker Toolbox\start.sh, and make a backup copy.
  2. Open the file C:\Program Files\Docker Toolbox\start.sh for editing.
  3. Look for this line: "${DOCKER_MACHINE}" create -d virtualbox "${VM}"
  4. Add a parameter to the line: "${DOCKER_MACHINE}" create –virtualbox-no-vtx-check -d virtualbox "${VM}"
  5. Save the file
    STEP 4

The Docker Toolbox installation adds an icon to the desktop labeled “Docker Quickstart Terminal”.  Click on this icon to run Docker for the first time. 

At this point the script will create the Docker virtual machine and attempt to configure it.  If the configuration proceeds successfully, you will have a running Docker instance.

In my case, configuration failed.  I received the following error, which seems to be not uncommon:

Error creating machine: Error in driver during machine creation: Unable to start the VM: C:\Program Files\Oracle\VirtualBox\VBoxManage.exe startvm default –type headless failed:

VBoxManage.exe: error: Failed to open/create the internal network ‘HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter #5’ (VERR_INTNET_FLT_IF_NOT_FOUND).

VBoxManage.exe: error: Failed to attach the network LUN (VERR_INTNET_FLT_IF_NOT_FOUND)

VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole

Details: 00:00:03.020271 Power up failed (vrc=VERR_INTNET_FLT_IF_NOT_FOUND, rc=E_FAIL (0X80004005))

To fix this error, I followed the instructions at https://caffinc.github.io/2015/11/fix-vbox-network/ to change the properties of the VirtualBox network adapter.  The key instructions are repeated here:

I opened my Control Panel > Network & Internet > Network Connections and located my VirtualBox Host-Only Network adapter, called VirtualBox Host-Only Network #6 on my machine. I right-clicked it and selected the Properties, and checked the un-checked VirtualBox NDIS6 Bridged Networking Driver and started VirtualBox again.

Then I used the VirtualBox Manager to delete the Docker virtual machine (named "default") and delete all associated files.

Once that additional configuration was complete, I was able to re-run the “Docker Quickstart Terminal” successfully.

Windows 7

Machine Specifications
  • 64-bit Windows 7
  • VT-X/AMD-v support enabled in the BIOS.
  • Latest version of VirtualBox (version 5.0.16 at the time of this writing) installed
Process

STEP 1

Download and install Docker Toolbox.

STEP 2

The Toolbox installation adds an icon to the desktop labeled “Docker Quickstart Terminal”.  Click on this icon to run Docker for the first time.  

At this point the script will create the Docker virtual machine and attempt to configure it.  If the configuration proceeds successfully, you will have a running Docker instance.

My configuration failed.  I received the following error:

Running pre-create checks…
Creating machine…
(default) Copying C:\Users\mlichtenberg\.docker\machine\cache\boot2docker.iso to
C:\Users\mlichtenberg\.docker\machine\machines\default\boot2docker.iso…
(default) Creating VirtualBox VM…
(default) Creating SSH key…
(default) Starting the VM…
(default) Check network to re-create if needed…
(default) Windows might ask for the permission to create a network adapter. Some
times, such confirmation window is minimized in the taskbar.
(default) Creating a new host-only adapter produced an error: C:\Program Files\O
racle\VirtualBox\VBoxManage.exe hostonlyif create failed:
(default) 0%…
(default) Progress state: E_INVALIDARG
(default) VBoxManage.exe: error: Failed to create the host-only adapter
(default) VBoxManage.exe: error: Assertion failed: [!aInterfaceName.isEmpty()] a
t ‘F:\tinderbox\win-5.0\src\VBox\Main\src-server\HostNetworkInterfaceImpl.cpp’ (
74) in long __cdecl HostNetworkInterface::init(class com::Bstr,class com::Bstr,c
lass com::Guid,enum __MIDL___MIDL_itf_VirtualBox_0000_0000_0036).
(default) VBoxManage.exe: error: Please contact the product vendor!
(default) VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component Ho
stNetworkInterfaceWrap, interface IHostNetworkInterface
(default) VBoxManage.exe: error: Context: "enum RTEXITCODE __cdecl handleCreate(
struct HandlerArg *)" at line 71 of file VBoxManageHostonly.cpp
(default)
(default) This is a known VirtualBox bug. Let’s try to recover anyway…
Error creating machine: Error in driver during machine creation: Error setting u
p host only network on machine start: The host-only adapter we just created is n
ot visible. This is a well known VirtualBox bug. You might want to uninstall it
and reinstall at least version 5.0.12 that is is supposed to fix this issue

To attempt to fix this error, I first followed the instructions at https://caffinc.github.io/2015/11/fix-vbox-network/ to change the properties of the VirtualBox network adapter.  The key instructions are repeated here:

I opened my Control Panel > Network & Internet > Network Connections and located my VirtualBox Host-Only Network adapter, called VirtualBox Host-Only Network #6 on my machine. I right-clicked it and selected the Properties, and checked the un-checked VirtualBox NDIS6 Bridged Networking Driver and started VirtualBox again.

This did NOT work.  However, I found additional advice online that suggested doing the opposite (checking the “VirtualBox NDIS6 Bridged Networking Driver” instead of unchecking), and then disabling and enabling the network adapter.

Disabling and re-enabling the network adapter may have been the key to resolving the error, but I cannot sure for sure.  In any case, I had success after 1) putting the properties of the network adapter back to their original state 2) and re-starting the network adapter.

Once the network adapter was reset, I used the VirtualBox Manager to delete the Docker virtual machine (named "default") and delete all associated files.

Once the additional configuration was complete, I was able to re-run the “Docker Quickstart Terminal” successfully.

Testing / Validation

On both Windows 7 and Windows 10, once the Docker installation completes successfully you will be left with a terminal window opened to a Docker command line.

An Internet connection is required for the following.

To test a basic Docker image, run the following command:

docker run hello-world

You will receive output that looks like the following:

Unable to find image ‘hello-world:latest’ locally
511136ea3c5a: Pull complete
31cbccb51277: Pull complete
e45a5af57b00: Pull complete
hello-world:latest: The image you are pulling has been verified.
Important: image verification is a tech preview feature and should not be
relied on to provide security.
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.
   (Assuming it was not already locally available.)
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.

 

That is it.  For next steps with Docker, reading the User’s Guide is a good place to start. 

If you want skip the specifics of Docker itself and dive right in to using a Docker container, pre-built Docker images for popular technologies such as nginx, Mongo, MySQL, Node, PostgreSQL, SOLR, ElasticSearch, and many others can be found at the Docker Hub.

Installing Mediawiki on Debian

Here are the steps to follow to install Mediawiki on Debian.  It is assumed that GNOME is in use on Debian. Installation on Windows or other flavors of Linux may vary.

If you have an existing Debian installation, skip right to the "Installing Mediawiki" section.  Otherwise, start with the "Preparing the Server" section.

PREPARING THE SERVER

The quickest way to get up-and-running, particularly if you are simply evaluating Mediawiki, is to use a pre-installed Debian virtual machine. 

NOTE: Alternately, you can set up Debian from scratch on a computer or in a virtual machine.  That process is beyond the scope of these instructions.  Refer to the Debian website for guidance.

To use a pre-installed virtual machine, follow these steps:

Step 1

Install VirtualBox, if you do not already have it.  It can be downloaded from https://www.virtualbox.org/.

Step 2

Download the appropriate pre-installed virtual machine from http://virtualboxes.org/.   For this tutorial, Debian 6.0.6 with GNOME was selected.

Step 3

Set up the virtual machine in VirtualBox.

Step 4

Start the virtual machine and log in.

Step 5

From the System/Administration menu, select Synaptic Package Manager.  You will be required to enter an administrative password.

Step 6

Use the Package Manager to search for "openssl".  If the installed version is between versions 1.0.1 and 1.0.1f (inclusive), it is vulnerable to the Heartbleed bug.  Do the following to upgrade it:

  1. Mark the "openssl" package for installation.
  2. If prompted to install/upgrade packages dependent on openssl, mark all of the additional packages for install/upgrade.
  3. Click the "Apply" button at the top of the Package Manager window.  Click the Apply button in the resulting dialog to confirm the changes.
  4. When prompted, close the dialog that reports that all changes were applied.  If you wish, review the details of the updates before closing the dialog.

INSTALLING MEDIAWIKI

Install Mediawiki by following these steps:

Step 1

From the Applications/Accessories menu, select Root Terminal to open a command prompt with administrative privileges.  When prompted, enter the administrative password.

Step 2

Update the list of package sources by typing

apt-get update

Step 3

Install the MySQL database management system by typing

apt-get install mysql-client mysql-common mysql-server

Step 4

When prompted, set a password for the "root" MySQL user.

Step 5

After the MySQL installation completes, open a MySQL command prompt by typing

mysql -u root -p <password>

Step 6

Create a new MySQL user named "mediawiki" and a password of "mediawiki" by typing

create user ‘mediawiki’ identified by ‘mediawiki’;

Step 7

Create a new database named "mediawiki" and grant the new "mediawiki" user rights by typing

create database mediawiki;
grant index, create, select, insert, update, delete, alter, lock tables on mediawiki.* to ‘mediawiki’@’localhost’ identified by ‘mediawiki’;
flush privileges;

Step 8

Type "exit" to leave the MySQL command prompt.

Step 9

Install the Apache HTTP server and PHP scripting language, along with all of the necessary add-ons, by typing

apt-get install apache2 libapache2-mod-php5 php5 php5-common php5-cli php5-mysql php5-mcrypt php5-curl php5-gd php5-intl php-pear

Step 10

Install Mediawiki and all extensions by typing

apt-get install mediawiki mediawiki-extensions

This may take a while (30-60 minutes).

Step 11

Open the php.ini file in the gedit text editor by typing

gedit /etc/php5/apache2/php.ini

Make the following modifications…

max_execution_time = 300
max_input_time = 120
memory_limit = 20M

as well as these additions…

extension=mysql.so
extension=gd.so

When done, close gedit.

Step 12

By default, Mediawiki is installed in /var/lib/mediawiki, rather than the default apache root folder.  Use gedit to open the 000-default configuration file by typing

gedit /etc/apache2/sites-enabled/000-default

Look for "DocumentRoot /var/www" and replace it with "DocumentRoot /var/lib/mediawiki".  Similarly, replace "<Directory /var/www/>" with "<Directory /var/lib/mediawiki/>".  When done, close gedit.

Step 13

Restart the apache service by typing

service apache2 restart

Step 14

Start a web browser and navigate to http://localhost/config

Step 15

Review the page and verify that the environment checks out and that you have been given the message "You can install MediaWiki".

Step 16

Fill out all required information.  For testing in a VM, you probably want to turn off all "E-mail" features.  Use the MySQL database information specified when installing MySQL to complete the "Database config" section.

Step 17

When done, click the "Install MediaWiki!" button.

Step 18

If everything completes successfully, you should see the message "Installation successful!", as well as directions for moving/installing the LocalSettings.php file.

Step 19

Move the LocalSettings.php file as directed.  (For example, move /var/lib/mediawiki/config/LocalSettings.php to /etc/mediawiki.)

Step 20

Navigate to http://localhost/index.php to see the home page of your newly installed Mediawiki instance.

 

RESETTING THE ADMIN PASSWORD

After completing the installation, I had a problem logging in using the administrative account.  I do not know if I made a mistake entering the password during the installation, or if there was a problem with the installation process itself.  So, just in case it is needed, here are the steps to reset the Mediawiki administrator password:

Step 1

Open a Debian command prompt with administrative rights.

Step 2

Navigate to the maintenance folder of the mediawiki installation (i.e.  /var/lib/mediawiki/maintenance).

Step 3

Change the password by typing

php changePassword.php –user=<adminusername> –password=<adminpassword>

ACCESSING MEDIAWIKI FROM THE HOST (VM INSTALL ONLY)

If you have installed Mediawiki in a virtual machine, and you want to access it from the host machine, follow these steps (originally described at http://stackoverflow.com/questions/6117610/how-to-access-oracle-db-in-virtualbox-from-host-windows):

Step 1

With the virtual machine turned off, use the VirtualBox Manager to open the Settings dialog for the virtual machine.

Step 2

Navigate to the "Network" tab.

Step 3

Adapter 1 should be enabled and attached to "NAT".  Leave this adapter active, as it will allow the virtual machine to access the Internet via the host machine’s network connection.

Step 4

Go to Adapter 2, check the "Enable network adapter" box, and set the value of the "Attached To" dropdown to "Host-only Adapter".  This adapter will allow the virtual machine to be accessed from the host.

Step 5

Start the virtual machine.

Step 6

Hover over the network icon on the status bar and note the IP address.  It should be similar to "192.168.56.101".

Step 7

From a browser on the host machine, navigate to the IP address (i.e. http://192.168.56.101).

 

Similarly, to enable administration of the Mediawiki MySQL database from the host machine, do the following:

Step 1

Within the virtual machine, open a command prompt with administrative rights.

Step 2

Use gedit to open the file /etc/mysql/my.cnf and comment out the line

bind-address = 127.0.0.1

This allows MySQL to accept connections from something other than the local machine.

Step 3

Restart the MySQL server by typing

service mysql restart

Step 4

Open a MySQL command prompt by typing

mysql -u root -p <password>

Step 5

Enable remote root access to MySQL by typing

grant all privileges on *.* to ‘root’@’%’ identified by ‘password’;

Set Up MongoDB on Windows in Five Minutes

Step 1: Download a ZIP file containing the appropriate version of MongoDB from MongoDB.org.

Step 2: Create the folder C:\MongoDB

Step 3: Extract the contents of the downloaded ZIP file to the new folder.

Step 4: Within the C:\MongoDB folder, create the folders C:\MongoDB\Data\DB.  This folder will hold the MongoDB databases.

Step 5: Open a command prompt and run C:\MongoDB\bin\mongod –dbpath C:\MongoDB\Data\DB.

You should see output that looks something like the following:

C:\mongodb\bin\mongod –dbpath c:\mongodb\data\db
Tue Nov 19 08:27:43.083 [initandlisten] MongoDB starting : pid=8608 port=27017 dbpath=c:\mongodb\data\db 64-bit host=s2ua3031x9m
Tue Nov 19 08:27:43.084 [initandlisten] db version v2.4.8
Tue Nov 19 08:27:43.084 [initandlisten] git version: a350fc38922fbda2cec8d5dd842237b904eafc14
Tue Nov 19 08:27:43.085 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack=’Service Pack 1′) BOOST_LIB_VERSION=1_49
Tue Nov 19 08:27:43.085 [initandlisten] allocator: system
Tue Nov 19 08:27:43.085 [initandlisten] options: { dbpath: "c:\mongodb\data\db"}
Tue Nov 19 08:27:43.122 [initandlisten] journal dir=c:\mongodb\data\db\journal
Tue Nov 19 08:27:43.123 [initandlisten] recover : no journal files present, no recovery needed
Tue Nov 19 08:27:43.206 [FileAllocator] allocating new datafile c:\mongodb\data\db\local.ns, filling with zeroes…
Tue Nov 19 08:27:43.207 [FileAllocator] creating directory c:\mongodb\data\db\_tmp
Tue Nov 19 08:27:43.246 [FileAllocator] done allocating datafile c:\mongodb\data\db\local.ns, size: 16MB,  took 0.037 secs
Tue Nov 19 08:27:43.247 [FileAllocator] allocating new datafile c:\mongodb\data\db\local.0, filling with zeroes…
Tue Nov 19 08:27:43.373 [FileAllocator] done allocating datafile c:\mongodb\data\db\local.0, size: 64MB,  took 0.125 secs
Tue Nov 19 08:27:43.374 [initandlisten] command local.$cmd command: { create: "startup_log", size: 10485760, capped: true } ntoreturn:1 keyUpdates:0  reslen:37 167ms
Tue Nov 19 08:27:43.375 [initandlisten] waiting for connections on port 27017
Tue Nov 19 08:27:43.375 [websvr] admin web console waiting for connections on port 28017

That’s it.  MongoDB is now running.

To verify that you can connect to the new MongoDB server, open a second command window and execute c:\mongodb\bin\mongo.

The Mongo shell will start.  You should see something like this:

C:\mongodb\bin\mongo
MongoDB shell version: 2.4.8
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
        http://docs.mongodb.org/
Questions? Try the support group
        http://groups.google.com/group/mongodb-user
>

More information is available in the MongoDB online tutorials, including how to set up MongoDB as a Windows service.