How using a Docker Container can aid demos in Sitecore 8

A Sitecore 8 instance requires a set of services working together, such as IIS, SQL Server and MongoDB. To prepare a demo website, these services need to be available, so our installation must ensure its presence and resolve any name conflicts with other databases or existing websites. The tool Sitecore Instance Manager can help you to install a Sitecore instance, although it still leaves you with a lot of manual work to do to install the customisations. 


I was wondering if Docker could help. It would be good to have a Docker image with a Sitecore demo already installed with all its dependencies, so it’s only necessary to instantiate a container to have a demo ready for the action. This way you don’t need to install or maintain software on the sales’ team laptop or on a cloud server. You only need a command to create the container with all that’s necessary. In this blog I will tell you more about this.  


What is Docker and why should I use it? 

There are loads of websites introducing Docker, so I won’t go into details. If you need help with it, you can search for “Introduction to Docker” on Google to find plenty of information. 


Explained in a high-level, Docker is a virtualisation system, similar to Hyper-V or VMWare. It has several benefits, but considering the purpose of this blog post, I would like to highlight the following benefits: 


  • It needs less disk space. The Docker containers need less disk space than traditional virtual machines. This is because various containers are sharing the same kernel, while traditional virtual machines have their own operating system (kernel). 

  • Because of other advantages being omitted in this article, Docker can be suitable for incorporating into modern development processes and software deployments (also called DevOps). The use of this technology for commercial demos is an easy way to get in contact with Docker and start using it. If it is already being used in our company, then this would be a new area/sector

Description of my Sitecore Demo 

The necessary software to support a Sitecore site depends on the Sitecore version and the characteristics and installed modules.

The Sitecore site used in this article is based on Sitecore 8 with the module Email Experience Manager (EXM) and with Experience Database (XDB) enables with a local MongoDB instance. The Search provider used is Lucene.  


Creating a Docker image for my Sitecore demo 

A Docker container is always being created from an image. A developer clould see it as instantiating an object (container) from its class (image). So, the first thing to do will be a Docker image with everything necessary for the demo. 


Necessary elements 

These are the elements that are necessary to create a Docker image with a Sitecore website.  
  • Machine with Docker 
  • Work folder 
  • File “Dockerfile” 
  • Sitecore files and databases 
  • Installation packages: 
    • SQL Server Express x64 
    • Microsoft Visual C++ 2012 Redistributable 
  • Folder with MongoDB files and configuration 
  • PowerShell scripts to install or enable the following prerequisites: 
    • SQL Server 
    • IIS 
    • MongoDB 
    • Microsoft Visual C++ 2012 Redistributable: required for Sitecore EXM. Only necessary if the Sitecore demo includes the “Email Experience Manager” module.

Below we will go through the details of each of these elements.  


Machine with Docker 

To create an image and then execute the containers, we need Docker. In this we use a machine with Windows 10 with “Docker for Windows”, although you can also use Windows Server 2016 and Apple or Linux.  


Docker needs to be configurated in “Windows containers” mode, this allows us to create Windows containers.  


Work folder

All the necessary for the website being created needs to be in one single folder. The name or address to this is irrelevant as it won’t be referenced from its interior. You can rename and move this in the future. In this case I have created it in:  


All the folders and files discussed below will be saved in this folder which we consider to be from scratch.  



The file “Dockerfile” (without extension) establishes the steps to follow by Docker to create the desired image. It must be created within the work folder at the root level. 



RUN powershell ./mongo.ps1 
# Setting up MongoDB 

RUN powershell ./iis.ps1 -Verbose 
# Setting up IIS and adding the website 

RUN powershell ./sql.ps1 -Verbose 
# Setting up MS SQL Server and attaching databases 

# Installing MS SQL Server 

RUN vcredist_x64.exe /passive /norestart 
# Install dependencies 

COPY . / 
# Adding the files 

LABEL Description="Sitecore 8.2 rev. 160729" Vendor="Sitecore" Version="8.2 rev. 160729" 

FROM microsoft/windowsservercore 


First of all you need to copy all the content into the root folder within the principal unit of the container (or image in this case) and establish the destination path as work folder. Next, all the necessary software is being installed using in some case the installation packages provided by the provider or using PowerShell scripts. 


In the next section we will see all the used elements for this Docker file. 


Sitecore files and databases 

The easiest way to install a Sitecore site with its corresponding personalisation is using the database and files from an environment where it is already working. It could be the same development environment where the corresponding personalisations (layouts, sublayouts, etc.) have been done. That’s what we are doing here.  


We create a folder in the root level called “sitecore”. In my case it’s: 


  • Data: Will contain the content from the “Data” folder from the site coming from the source/original environment. You can empty all the folders except for the “indexes” in this way we will keep the Lucene indexes while reducing the size of the image and Docker containers. The “Data” folder is the place where, by default, the Sitecore licence file ("license.xml") is being saved. A valid license file must be used. 

  • Databases: Will contain the SQL Services databases used by the website. In my case they are the following (with its corresponding log files): 
    • Sitecore.Core.mdf 
    • Sitecore.Exm.Master.mdf 
    • Sitecore.Exm.Web.mdf 
    • Sitecore.Master.mdf 
    • Sitecore.Reporting.mdf 
    • Sitecore.Web.mdf 
  • Website: Will contain the website files. It can be obtained from the folder indicated by the IIS server of the source environment.  

Installation packages 

Two of the requirements of our Sitecore site are installed through redistributable packages, such as: 

SQL Server Express x64: You can download it here. This package is installed by the file "dockerfile" with the following line: 




Microsoft Visual C++ 2012 Redistributable: You can download it here. The line, inside the file "dockerfile" responsible for its installation is: 


RUN vcredist_x64.exe /passive /norestart 


Folder with MongoDB files and configuration 

The installation and administration details of MongoDB are beyond the scope of this document. To simplify things, you can copy files from a MongoDB instance of a development environment, where sharing, replication, or any advanced MongoDB features are not usually applied. We will need the "bin" folder with the MongoDB binaries, the "data" folder with the databases, and if there is a "config" with a configuration file that, being optional, facilitates the task of indicating to MongoDB where you can find the folders of data and logs, along with other details such as the storage engine etc. 


A detail to take into account in the configuration of MongoDB is that the complete path to the necessary folders, inside the container will be different to the path where they are saved on the machine where the Docker image will be created. For example, in my development environment the folder with the MongoDB databases is in "c:\docker\scdemo\MongoDB\3.4\data\dbs", instead, in the MongoDB configuration file (used within the container) the path will be "c: /MongoDB/3.4/data/dbs". As we can see, the root directory where the container image is created ("c:\docker\scdemo\") becomes the root path ("c:/") inside the container. 


An example from a MongoDB configuration file would be the following: 


  #logRotate: reopen
  #logAppend: true 
  # Append to existing log file 
  logRotate: rename 
  # Rename existing log file and create a new one 
  # Log files management: 
  path: "c:/MongoDB/3.4/data/logs/mongod.log" 
  destination: "file" 
  engine: wiredTiger 
  # Wired Tiger: It 
  #engine: mmapv1 
  # Memory Map: 
  # Storage Engine: 

  directoryPerDB: true 
  # Stores each DB within a folder (not default) 
  dbPath: "c:/MongoDB/3.4/data/dbs" 


PowerShell scripts to install or enable prerequisites  

 The file “dockerfile”, is supported by the following PowerShell scripts for the tasks described below. 
  • “sql.ps1”: Configure SQL Server to ensure access to Sitecore and attach the necessary databases: 

Set-StrictMode -Version latest ; 

Server\MSSQL14.SQLEXPRESS\MSSQLServer\SuperSocketNetLib\Tcp\IPAll' -Name TcpDynamicPorts -Value '0' 
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL 
Server\MSSQL14.SQLEXPRESS\MSSQLServer\SuperSocketNetLib\Tcp\IPAll' -Name TcpPort -Value '1433' ; 
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL 
Server\MSSQL14.SQLEXPRESS\MSSQLServer' -Name LoginMode -Value 2 ; 
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL 
Start-Service MSSQL`$SQLEXPRESS ; 
ServerInstance ".\SQLEXPRESS" ; 
Invoke-Sqlcmd -Query "ALTER LOGIN sa with password='saPassword'; ALTER LOGIN sa ENABLE;" -

'C:\sitecore\Databases\demo.local_core_log.ldf')       FOR ATTACH ;" -ServerInstance ".\SQLEXPRESS" 
'C:\sitecore\Databases\Sitecore.core.mdf'),       (FILENAME = 
Invoke-Sqlcmd -Query "CREATE DATABASE [demo.local_core]       ON (FILENAME = 

'C:\sitecore\Databases\demo.local_exm.master_log.ldf') FOR ATTACH ;" -ServerInstance ".\SQLEXPRESS" 
'C:\sitecore\Databases\Sitecore.exm.master.mdf'), (FILENAME = 
Invoke-Sqlcmd -Query "CREATE DATABASE [demo.local_exm.master] ON (FILENAME = 

'C:\sitecore\Databases\demo.local_exm.web_log.ldf')    FOR ATTACH ;" -ServerInstance ".\SQLEXPRESS" 
'C:\sitecore\Databases\Sitecore.exm.web.mdf'),    (FILENAME = 
Invoke-Sqlcmd -Query "CREATE DATABASE [demo.local_exm.web]    ON (FILENAME = 

'C:\sitecore\Databases\demo.local_master_log.ldf')     FOR ATTACH ;" -ServerInstance ".\SQLEXPRESS" 
'C:\sitecore\Databases\Sitecore.master.mdf'),     (FILENAME = 
Invoke-Sqlcmd -Query "CREATE DATABASE [demo.local_master]     ON (FILENAME = 

'C:\sitecore\Databases\demo.local_reporting_log.ldf')  FOR ATTACH ;" -ServerInstance ".\SQLEXPRESS" 
'C:\sitecore\Databases\Sitecore.reporting.mdf'),  (FILENAME = 
Invoke-Sqlcmd -Query "CREATE DATABASE [demo.local_reporting]  ON (FILENAME =  ; 
'C:\sitecore\Databases\demo.local_web_log.ldf')        FOR ATTACH ;" -ServerInstance ".\SQLEXPRESS" 
'C:\sitecore\Databases\Sitecore.web.mdf'),        (FILENAME = 
Invoke-Sqlcmd -Query "CREATE DATABASE [demo.local_web]        ON (FILENAME = 


  • “iis.ps1”: Create and configure the demo website within Internet Information Services (IIS):Add-WindowsFeature Web-Server 

Add-WindowsFeature NET-Framework-45-ASPNET 
Add-WindowsFeature Web-Asp-Net45 
C:\Windows\System32\inetsrv\appcmd.exe delete site "default web site" 
C:\Windows\System32\inetsrv\appcmd.exe add site /name:Sitecore /bindings:http/*:80: 
# Site Bindings 
New-WebBinding -name Sitecore -port 80 -Protocol http -HostHeader demo.local -IPAddress "*" 
New-WebBinding -name Sitecore -port 80 -Protocol http -HostHeader demo.demo.local -IPAddress "*" 
New-WebBinding -name Sitecore -port 80 -Protocol http -HostHeader habitat.demo.local -IPAddress "*" 
New-WebBinding -name Sitecore -port 80 -Protocol http -HostHeader legal.demo.local -IPAddress "*" 
New-WebBinding -name Sitecore -port 80 -Protocol http -HostHeader retail.demo.local -IPAddress "*" 
New-WebBinding -name Sitecore -port 80 -Protocol http -HostHeader finance.demo.local -IPAddress "*" 
New-WebBinding -name Sitecore -port 80 -Protocol http -HostHeader storefront.demo.local -IPAddress "*" 
New-WebBinding -name Sitecore -port 80 -Protocol http -HostHeader utilities.demo.local -IPAddress 
C:\Windows\System32\inetsrv\appcmd.exe start site Sitecore iisreset 


  • “mongo.ps1”: Configure the Windows service that will run MongoDB: 

Get-Service | Where-Object {$_.displayName -eq "MongoDb"} | Start-Service 
c:\MongoDB\3.4\bin\mongod.exe --service --config=c:\MongoDB\3.4\config\mongod.cfg --install 


Docker image creation process 

Once the necessary elements are prepared, the creation of the image consists of executing the following command: 


docker build -t sitecore %~dp0 


Instance a Docker container with my Sitecore Demo 

Once we have our Docker image, create a container with the demo ready to be used, it is as simple as executing the following command: 


docker run --name sitecore -p 80:80 -it -m 8g sitecore powershell 


Once the container is executed, we will access it through its IP. The following PowerShell command can be used to obtain this IP: 


docker inspect --format '{{ .NetworkSettings.Networks.nat.IPAddress }}' sitecore 


The version of Docker for Windows 10 has certain limitations that prevent access to the Sitecore site in the container through a more friendly domain (such as "localhost"). More information can be found here. Fortunately, the Docker version for Windows Server 2016 solves this limitation. 



The following articles where very useful while developing this Docker solution. 

More information about Docker to come next week in my new blog!

Author bio

Benjamin Moles
Benjamin Moles
Sitecore Developer
My goal is to return happiness to clients' faces by getting their issues and questions solved. As a Technical Service Manager I provide the required resources to support clients' applications and infrastructure. I also enjoy playing with remote-controlled helicopters.


comments powered by Disqus

Related Articles

Sign up to our ClearThought newsletter

Get inspired and learn something new by subscribing to our FREE newsletter. It’s full of ClearPeople's thought-leadership whitepapers, blogs, events, and much more. We promise to not use your email for spam.

Closing this message and/or accessing our website tells us you are happy to receive all cookies on the ClearPeople website.
However, if you would like to, you can change your cookies settings at any time.