Search for:
docker container software development

Docker container: Next Big Thing in Software Development 4/4

Here we go! We’ve just reached the last post of a series of four! In the previous posts, among a bunch of cool stuff, you were presented to Docker container with all the benefits it brings, learned how to set up the best software development environment ever and started playing with eShopOnWeb, a Microsoft sample web application using ASP.Net Core. To follow the instructions below, I recommend reading all previous posts. There are precious instructions and pre-requisites to follow some of the next steps.

Now let’s take eShopOnWeb to another level. We will build a SQL Server 2019 image and run a container so that eShopOnWeb can persist data.

First, to accomplish this task, we will choose an already built image of SQL Server 2019. We always recommend you use official docker images from all vendors or communities that support their products. Many of them publish and maintain their images updated. Go to dockerhub.com, fillup the search field with SQL Server and hit Enter.

dockerhub sql server 2019

Click on the Microsoft SQL Server link to take you to choose one of the Featured Tags. Scroll down a little, so you will see the tag 2019-latest, which is the one we are going to use. Spend a little time to read and explore the page to get used to all the tags and options in the Description tab and the Reviews tab and Resources tab with rich Support and Documentation content.

docker hub sql server 2019 latest tag

Now that you were formally presented to Docker Hub let’s run a docker container based on the Microsoft official Docker image of SQL Server 2019, which, by the way, runs in a Ubuntu 18.04.5 LTS distribution.

Go to Windows Terminal, open a Ubuntu shell prompt and run this command docker volume create eShopOnWeb-data to create a docker volume to store SQL Server data.

docker volume create eShopWeb data

In Docker’s world, there are two mechanisms to persist data: using bind mounts and the other is the use of volumes. In the docker official documentation, you will see that there many advantages to using volumes over bind mount as follows:

  • Volumes are easier to back up or migrate than bind mounts.
  • You can manage volumes using Docker CLI commands or the Docker API.
  • Volumes work on both Linux and Windows containers.
  • Volumes can be more safely shared among multiple containers.
  • Volume drivers let you store volumes on remote hosts or cloud providers, encrypt the contents of volumes, or add other functionality.
  • New volumes can have their content pre-populated by a container.

If you want to explore more about it, click here and find out.

A docker container for SQL Server 2019

For the next step, make sure port 1433 is not being used on your machine. For doing so, you can stop an eventual SQL Server service running locally.

Next step, we will run the container using this volume eShopOnWeb-data. Therefore copy this command below and hit Enter.

docker run `
-e "ACCEPT_EULA=Y" `
-e "SA_PASSWORD=MyP4ssw0rd" `
-p 1433:1433 `
-d `
--name eShopOnWeb_MSSQL2019 `
-u root `
--mount source=eShopWeb-data,target=/var/opt/mssql/data `
mcr.microsoft.com/mssql/server:2019-latest

Explaining all docker run command parameters:

-e "ACCEPT_EULA=Y": sets the required SQL Server image environment variable ACCEPT_EULA to Yes;
-e "SA_PASSWORD=MyP4ssw0rd": sets the required SQL Server image environment variable to set up a password for the user sa;
-p 1433:1433: sets the port to be exposed to the host machine. The colon right-hand side is the container port that maps to the host port in the colon left-hand side;
-d : allows the container to run in detached mode;
--name eShopOnWeb_MSSQL2019 : gives a friendly name to the container;
-u root: grant the proper rights as root user for mapping the database local container database directory to the newly created volume eShopOnWeb-data in the host;
--mount source=eShopWeb-data,target=/var/opt/mssql/data: mounts the database directory in the container to the volume in the host;
mcr.microsoft.com/mssql/server:2019-latest : the image and its tag docker will use to create the container.

docker run sql server 2019

Open eShopOnWeb in VSCode by typing code . in the eShopOnWeb directory.

open eShopOnWeb in VSCode via Powershell

Click on the Reopen in Container button and wait a couple of seconds until it reopens into Dev Container.

In VSCode Reopen in container

Go to extensions, type SQL Server in the Search field, select SQL Server (mssql) 1.9.0 and click on Install in Dev Container: eShopOnWeb green button shown below.

mssql for Visual Studio Code

It takes a few seconds to install it. When it finishes the installation, click on the SQL Server extension, which is the button right below the Docker button, to set up a connection.

click plus button to setup a connection

Let’s connect to SQL Server. First of all, find out your machine IP address, which is the host of the SQL Server 2019 container, by  typing ipconfig command on Powershell or Windows Terminal.

find out IP address via ipconfig command

My machine IP address is 192.168.2.217.

Click on the “Add Connection” button, type the IP address in the command palette and hit Enter.

conn mssql - type ip address in the command palette

Leave the default database connection blank and press Enter.

conn mssql - default database

Select the SQL Login option for connection.

conn mssql - select SQL Login option

Type sa for User Name (SQL Login) and hit Enter.

conn mssql - type sa for User name

Type the password defined on docker run command, which is MyP4ssw0rd and hit Enter.

conn mssql - type sa password

Select Yes to save the password.

conn mssql - save sa password

And finally, give the connection profile the name eShopOnWeb-mssql2019 and hit Enter.

conn mssql - connection profile name

Now you got it! You’ve just connected to SQL Server 2019 database in another Linux docker container from within your Linux Dev Container using the host machine via 1433 port.

connected to eShopOnWeb-mssql2019 database

Let’s query the database to make sure it is working. Right-click on the server node, select the New Query menu option.

querying database - right click on the server node

A new window will show up, type. select @@version.

querying database - typing select command

Highlight the command, right-click on it and select the Execute Query menu option.

querying database - execute query

And you will see the result on the right side.

querying database - query result

Cool Software Development environment explained!

What we have here is your Dev Container talking to SQL Server 2019 container through host under port 1433. Check this typing docker ps -a See the Linux containers up and running, and more importantly, in your Windows 10, cool, right?!

Dev Container and SQL Server 2019 containers up and running

Now, let’s change the eShopOnWeb application to persist data in SQL Server 2019.

Search for the ConfigureDevelopmentServices method.

search for ConfigureDevelopmentServices method
  • Update Startup.cs ConfigureDevelopmentServices method as follows:

Comment on the line below "// use in-memory database"

use real database on PublicApi

Uncomment the line below "// use a real database"

use real database on Web
  • Ensure your connection strings in appsettings.json‘s on Web and PublicApi folders are pointing to the newly created SQL Server 2019 in Linux container. Remember to replace the IP address.

Replace existing "CatalogConnection" and "IdentityConnection" keys in the"ConnectionStrings"object by:
"CatalogConnection": "Server=192.168.2.217;Integrated Security=false;User ID=sa;Password=MyP4ssw0rd;Initial Catalog=Microsoft.eShopOnWeb.CatalogDb;",
"IdentityConnection": "Server=192.168.2.217;Integrated Security=false;User ID=sa;Password=MyP4ssw0rd;Initial Catalog=Microsoft.eShopOnWeb.Identity;"

replace connection string in appsetings config in PublicApi
replace connection string in appsetings config in Web

Don’t forget to save the changes!

  • Open an integrated terminal in the Web folder.
open integrated terminal on web folder
  • Ensure the tool EF was already installed by typing this command dotnet tool install --global dotnet-ef
donet ef tools aready installed
  • Execute the following commands:
dotnet restore 
dotnet tool restore 
dotnet ef database update -c catalogcontext -p ../Infrastructure/Infrastructure.csproj -s Web.csproj 
dotnet ef database update -c appidentitydbcontext -p ../Infrastructure/Infrastructure.csproj -s Web.csproj

These commands will create two separate databases, one for the store’s catalogue data and shopping cart information, and one for the app’s user credentials and identity data.

create catalogcontext database
create appidentitydbcontext database
  • Now run the application. Go to the menu Run and select Run Without Debugging.
run without debugging

The first time you run the application, it will seed both databases with data such that you should see products in the store, and you should be able to log in using the demouser@microsoft.com account.

eShopOnWeb running on SQL Server 2019

Now it’s running on SQL Server 2019. Click in Login and connect with demouser@microsoft.com and password Pass@word1.

eShopOnWeb login

Add some products to the basket.

adding some products to the basket

And Checkout.

eShopOnWeb checkout
  • Let’s check the SQL Server 2019 database. Go to SQL Server extension and open Database node, and you will see the CatalogDb and Identity databases created in the previous steps.
checking SQL Server database

Open CatalogDb node and then Tables node, right-click on dbo.Baskets and choose the Select Top 1000 menu option.

querying eShopOnWeb baskets

See that there is one record in the dbo.Baskets table.

one record on eShopOnWeb basket

Right-click on dbo.BasketItems and hit Select Top 1000 again to see the items you chose.

three records in the BasketItems table

We’ve just reached our goal with this fourth and last post of this series. Now we have a versatile, tidy, rich and hybrid software development environment using cutting-edge technology.

To access the source code of this project on our GitHub, click here.

I am preparing exciting content for the following posts. We will set up Reverse Proxy using Nginx, automated tests with Jenkins CI/CD platform and more. Subscribe, make suggestions for the next posts!

Do you want to know more about us and our mission? Click here, and don’t forget to subscribe!

We also have pro bono projects just in case you are interested in learning more about them.

Be aware of why we started this project by clicking here.

Learn more about other posts here.

Contact us for any suggestions. And follow us on FacebookInstagram and Twitter.

If you are a good reader like myself, I recommend the following readings:

  • Docker Quick Start Guide: Learn Docker like a boss, and finally own your applications
  • Docker for Developers: Develop and run your application with Docker containers using DevOps tools for continuous delivery

See you in the next post!

docker container software development

Docker container: Next Big Thing in Software Development 3/4

This post is the third of a series of four. You might have missed the two essential steps to guide you by preparing a unique, modern, multi-purpose and tidy software development environment. In the first one, we explain what Docker, docker container,  WSL are. How to install them, and all benefits we can get from having such a hybrid and powerful machine. In the second one, We help you set things up to make the most of this current post. But if you have been following me, congrats, we will see more cool stuff now!!

First, let’s define what we will use to demonstrate Docker and containerized applications’ power.

There are many software frameworks, architectures and platforms we could use to show off our new development environment, but there is one I want to focus on, ASP.Net Core, which is currently in version 3.1 at the time of this post.

Asp.NET Core - Sharing

Why ASP.Net Core?

Because it’s is the open-source version of ASP.NET, which runs on macOS, Linux, and Windows. ASP.NET is a popular web development framework for building web apps on the .NET platform. Over 60,000 developers and 3,700 companies have already contributed to .NET on GitHub.

It’s faster than other popular web frameworks based on the independent TechEmpower benchmarks.

Lifecycle and reliable support policy

Its modern and innovative design allow runtime components, APIs, compilers and languages evolve rapidly while still providing a supported and stable platform to keep apps running.

On the same server, multiple versions of ASP.NET Core will exist side by side. That means the new release can be adopted by one app, while other apps continue to run on the version on which they were tested.

To meet the needs of your app, ASP.NET Core offers different support lifecycle options. If you commit to updating more often, you can select a long-term support release or run with the new update.

Having said that, with all the above-described concerns a good developer needs to address, let’s pick one application to containerize using Docker. Therefore we chose eShopOnWeb, a sample ASP.NET Core 3.1 reference application, powered by Microsoft, demonstrating a layered application architecture with a monolithic deployment model using the SQL Server database persistence.

Let’s clone the eShopOnWeb application using git.

Git - Sharing

If you don’t know what git is, here is the most straightforward way to tell you. Git is a version control system (VCS) type that makes it easier to monitor file modifications. When you edit a file, git will help you decide what has changed, who has changed it, and why. Git isn’t the only system out there for version control, but it’s by far the most popular among developers.

Furthermore, besides all of that, it has a useful command called git clone that magically downloads everything you need about the project.

Click here to download git for Windows, click on the downloaded executable and follow the instruction. Go all the way to the end by clicking the Next button and keeping all default options as they appear.

Open Powershell or Windows Terminal (recommended), go to a directory of your preference and type git clone https://github.com/dotnet-architecture/eShopOnWeb.git as shown below.

git clone eShopOnWeb

You will have all source code right in your local machine in less than a minute, ready for the entire software development workflow in a containerized environment.

git clone eShopOnWeb ready

Go to eShopOnWeb newly created folder by typing cd .\eShopOnWeb\ and hit Enter.

eShopOnWeb folder

To open the Visual Studio Code (VSCode) in a stylish mode, type code . and hit Enter.

open vscode

It will open VSCode with two notifications, as shown below.

open vscode

First, click on the “Install” button to install all recommended extensions for this repository. It is going to take a couple of minutes to install the following:

  1. C# for Visual Studio Code (powered by OmniSharp) with the following features:
    • Lightweight development tools for .NET Core.
    • Comprehensive C# editing support, including Syntax Highlighting, IntelliSense, Go to Definition, Find All References, etc.
    • Debugging support for .NET Core (CoreCLR). NOTE: Mono debugging is not supported. Desktop CLR debugging has limited support.
    • Support for project.json and csproj projects on Windows, macOS and Linux.
  2. Test Explorer for .NET Core
    • Use Test Explorer to run unit tests from Visual Studio or third-party unit test projects. You can also use Test Explorer to group tests into categories, filter the test list, and create, save, and run playlists of tests. You can also analyze code coverage and debug unit tests.
  3. Azure Tools for Visual Studio Code
    • Microsoft Azure support for Visual Studio Code is provided through a rich set of extensions that make it easy to discover and interact with the cloud services that power your applications. Click here for more details.
  4. Visual Studio Code Kubernetes Tools
    • They are intended for developers building applications to run in Kubernetes clusters and for DevOps staff troubleshooting Kubernetes applications. Work with any Kubernetes anywhere (Azure, Minikube, AWS, GCP and more!). Click here for more details.
  5. YAML Language Support by Red Hat
    • This extension provides a comprehensive YAML Language support to Visual Studio Code, via the yaml-language-server, with built-in Kubernetes syntax support. Supports JSON Schema 7 and below. Click here for more details.

After installing all extensions, you will see another notification.

vscode with all extensions installed

Click on “Restore” to resolve all dependencies for this solution (eShopOnWeb.sln). Dependencies are all required pieces of software to run the solution. A solution is a name given to a structure for organizing projects.

Wait for less than a minute to finish the restoring process and close VSCode. Open it again via Powershell or Windows Terminal, typing code . and hitting Enter.

You will see the last notification related to the Dev Container configuration file.

Dev Container for VSCode

If you choose the “Don’t show again” button, it will use your Windows with all extensions and dependencies already installed and ready to go. If you go with the “Clone in volume” button, it will save them in a Docker volume for persistence purposes.

For now, click on “Reopen in Container” and wait a couple of minutes until it creates a docker container for your development environment with all extensions and dependencies running in Ubuntu 18.04.5 LTS.

VSCode Dev Container in Ubuntu

You can tell it’s running on a container by the green indication saying “Dev Container: eShopOnWeb” in the left bottom corner at the status bar.

Now go to the Run menu and select the “Run Without Debugging” option.

Run eShopOnWeb

It will restore, build into the Linux container and automatically run the application in your preferred web browser on http://localhost:5001 in your local machine (host).

eShopOnWeb running

Software development in a docker container

What they did was it, they allowed you to develop inside this docker container. Type docker ps and hit Enter to see all your running containers.

VSCode Dev Container

This container is a runtime instance of this docker image. Type docker images and hit Enter to see all your built images.

If we dive into the image, we will see that it contains all the dependencies installed in Ubuntu, as we talked about earlier to make what we call a Dev Container.

Dive Dev Container

As a full-featured development environment, the VSCode Remote-Containers extension enables you to use a Docker container. It lets you open any folder inside or mounted into a docker container and take advantage of the full feature set of VS Code. In your project, the devcontainer.json file tells VS Code how to access or create a development container with a well-defined runtime stack and tool. This container can run an application or run the required sandbox tools, libraries, or runtimes for a codebase to work correctly.

Workspace files are placed or copied, or cloned from the local file system into the container. Extensions are mounted and run within the container, where the tools, software, and file system are entirely accessible. It means that only by connecting to a separate container can you effortlessly alter your entire development environment, which makes a huge difference when working on many different projects requiring various dependencies.

Architecture Containers VSCode

All of this allows VS Code to provide a development experience of local consistency, including complete IntelliSense for code completion, code navigation and debugging, no matter where your tools or code are located.

Congratulations, you have finally set up an exquisite software development environment to improve your productivity and provide you with a local-quality development experience.

Do you want to know more about us and our mission? Click here, and don’t forget to subscribe!

We also have pro bono projects just in case you are interested in learning more about them.

Be aware of why we started this project by clicking here.

Learn more about other posts here.

Contact us for any suggestions. And follow us on FacebookInstagram and Twitter.

If you are a good reader like myself, I recommend the following readings:

  • Docker Quick Start Guide: Learn Docker like a boss, and finally own your applications
  • Docker for Developers: Develop and run your application with Docker containers using DevOps tools for continuous delivery

See you in the next post!

docker container software development

Docker container: Next Big Thing in Software Development 2/4

This post is the second of a series of four. I recommend you read the first one since we explain what Docker, docker container,  WSL is, how to install them, and all benefits we can get from having a flexible and versatile software development environment.

Let’s get started!

If you reached the end of the previous post, you might have got Docker Desktop up and running in your tray icon.

docker running

If Docker is not running yet, start Docker Desktop from the Windows Start menu, wait a couple of seconds until it loads completely, right-click at the whale icon and do the following:

  • Make sure that the “Switch to Windows containers…” option is showing up; go to the next step; if it’s not, select “Switch to Linux containers…” wait a couple of seconds and then go to the next step.
  • Select Settings
Docker Desktop settings
  • Select General on the left panel, click the Use WSL 2 based engine checkbox. If you have installed Docker Desktop on a system that supports WSL 2, this option will be enabled by default.
Docker Desktop
  • Click Apply & Restart.
  • Ensure the distribution runs in WSL 2 mode. WSL can run distributions in both v1 or v2 manner. To check the WSL mode, go to Powershell or Windows Terminal and run: wsl -l -v

If needed, to upgrade your existing Linux distro to v2, run:  wsl --set-version distro name 2, here the distro name is Ubuntu-20.04.

To set v2 as the default version for future installations, run:  wsl --set-default-version 2

  • Go to Settings > Resources > WSL Integration, select any additional distributions you would like to enable WSL 2.
Docker Desktop wsl2- choose distro

For more information about installing Linux distros go to my first post and see the Install your Linux distribution of choice section for details.

  • Click Apply & Restart.

Why WSL 2 for your software development environment?

To explain what we just did, we unveiled the WSL 2 powerful feature, which is predominantly a developer tool — mainly for but not limited to web developers and those who work on or for open source projects. WSL facilitates those who want or need to use Bash, popular Linux tools (sed, awk, etc.) and various Linux-first tools (Ruby, Python, etc.) to use their Windows development environment.

WSL provides an application named Bash.exe that opens a Windows console running the Bash shell when it is installed. Using Bash, you can run Linux software and applications on the command-line, but, as I said in the previous post, I recommend using Windows Terminal due to its numerous useful features. Use the down arrow on the right of the plus sign to open a bash terminal. Type cat /etc/*release and hit enter, for example; you will see details of the currently running Linux distro:

Linux Distro - Release Info

Bash is a very popular and vastly used text-based shell and command-language. It is the default shell included within Ubuntu and other Linux distributions and in macOS. Users usually type commands into a shell to execute scripts and run commands and tools for many tasks the same way we use Powershell.

You can also access the filesystem of your machine from inside the shell of Linux Bash – you can find your local drives mounted under the folder /mnt. Your C: drive, for instance, is installed under /mnt/c

Sharing Windows Filesystem

Mount points for hard drives on your machine are automatically created and provide easy access to the Windows filesystem (e.g. /mnt/<drive letter>/).

The CI/CD pipeline can exemplify a typical development workflow that incorporates WSL2. Let’s say that I want to test it first on a local machine before deploying it to the cloud. I can enable WSL2 and then use a genuine Linux Ubuntu instance locally (on my laptop) with whatever Bash commands and tools I prefer. Once the development pipeline is verified locally, I can then push that CI/CD pipeline up to the cloud (e.g. Azure) by making it into a docker container and moving it to a cloud instance where it runs on a production-ready Ubuntu virtual machine.

Installing Visual Studio Code on Windows 10 – VSCode for short

Note: .NET Framework 4.5.2 or higher is a requirement for VSCode. You can check your version of .NET Framework using this command: reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\full" /v version from a command prompt.

.Net Framework version
  1. Download the Visual Studio Code installer for Windows.
  2. Once it is downloaded, run the installer (VSCodeUserSetup-{version}.exe). It will only take a minute.
  3. By default, VS Code is installed under C:\users\{username}\AppData\Local\Programs\Microsoft VS Code.

Develop using docker container and WSL2

This section will describe how to start your software development environment with Docker and WSL 2. We always recommend that you have your code residing in your default Linux distribution for a better development experience using Docker and WSL2. After enabled WSL2 on Docker Desktop, you can start working with your code inside the Linux distro and ideally with your IDE still in Windows. This workflow can be pretty straightforward if you are using VSCode.

  • Open VSCode and install the Remote – WSL extension. It will take you to Visual Studio Marketplace. Click on install.
VSCode Marketplace

It will take you to VSCode already installed. Click on the green Install button right beside the penguin.

Remote WSL - VSCode

The extension allows you to work with a remote server in the Linux distribution and your IDE client on Windows.

  • Now, let’s start working in VSCode remotely. To do so, open your Windows Terminal and type:wsl and press Enter.

Type code . and press Enter. It will take a couple of seconds until VSCode shows up.

download vscode from linux

It will open a new VSCode connected remotely to your default Linux distro, which you can check in the bottom left corner of the screen.

Alternatively, you can type the name of your default Linux distro in your Start menu, open it, and then run.: code . 

  • When you are in VSCode, you can use the terminal in VSCode to pull your code and start working natively from your Windows machine.

Congratulations, you have accomplished the second step of a series of four. You will soon experiment with a great software development environment using Windows and Linux to host parts of an application using the docker container concept and the Visual Studio Code. We will install Oracle and SQL Server Databases, IIS Application Server, Reverse Proxy with the very popular Nginx, NodeJS platform and some other useful tools and tips to help us to improve your productivity.

Do you want to know more about us and our mission? Click here, and don’t forget to subscribe!

We also have pro bono projects just in case you are interested in learning more about them.

Be aware of why we started this project by clicking here.

Learn more about other posts here.

Contact us for any suggestions. And follow us on FacebookInstagram and Twitter.

If you are a good reader like myself, I recommend the following readings:

  • Docker Quick Start Guide: Learn Docker like a boss, and finally own your applications
  • Docker for Developers: Develop and run your application with Docker containers using DevOps tools for continuous delivery

See you in the next post!

docker container software development

Docker container: Next Big Thing in Software Development 1/4

Software Development

Depending on what type of software product you are developing, the technologies involved. Even the architecture you are going to choose to perform this task, you will need to install and set up a bunch of different stuff in your machine and spend lots of hours, sleepless nights and sweat to come up with the “state of the art” software as the final result.

It’s also common sense that every software product has its lifecycle, and it’s your responsibility to guarantee its evolution along with all the libraries, frameworks and many other pieces of software you tirelessly used to build it! It’s not fair that with all effort you have put into building software with all the invaluable skills, you still have to deal with some inevitable environmental issues caused by too much stuff cluttered on your computer!!

You might have caught yourself in this somewhat horrible situation during the application development at least once in your life as a developer, haven’t you?!

Hopefully, there is a solution to this, and the answer is a Docker container!!

A modern and versatile environment with Docker

How about building a modern and versatile software development environment with:

  • Multiple operating systems, sharing their file systems (e.g. Linux, Windows, etc.)
  • Version control (e.g. GitHub, Subversion, etc.)
  • Multiple databases (e.g. Oracle, SQL Server, MySQL, Redis, MongoDB, etc.)
  • Application Infrastructure (e.g. Node.js, Nginx, Apache HTTP Server Project, etc.)
  • Software Runtime/Development Kit (e.g. Microsoft .NET, Java, etc.)
  • Unit test and end-to-end automated web testing tools

All of that using one of the most popular source code editor Visual Studio Code in your 16Gb RAM (recommended) machine!!

That’s what we are going to do, but first things first! We need to address some basic concepts before we jump into a better software development environment.

docker container software development

What is Docker?

There are many definitions out there with, most of the time, a bunch of unnecessarily complicated terms, but here is the one I like the most: “It’s a tool designed to make it easier to create, deploy, and run applications by using a container.”

OK, but what is a docker container, though?

A container is a standard unit of software that packages up code and all its dependencies, so it runs quickly and reliably from one computing environment to another. It is a lightweight, standalone, executable software package that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.

Now you know what Docker is, let’s make it happen!

There are two different versions of Docker, Enterprise Edition (Docker EE), which paid and Community Edition (Docker CE), the free one. Let’s stick with Docker CE.

There are many ways to install Docker. It’s possible to install it directly on Mac, Linux (CentOS, Fedora, Raspbian and Ubuntu) or Windows. For this series of posts, we are going to install Docker Desktop for Windows. You can follow the link, or you can follow me here for better convenience:

  • You can either download the stable or edge version, it’s up to you, but it’s essential to be mindful about this.
    • Stable:
      • Stable is the best channel to use if you want a reliable platform to work. Stable releases track the Docker platform stable releases.
      • You can select whether to send usage statistics and other data.
      • Stable releases happen once per quarter.
    • Edge:
      • Use the Edge channel if you want to get experimental features faster and weather some instability and bugs.
      • Always collect usage data on Edge releases.
      • Edge builds are released once per month.
  • Depending on your internet connection, it takes less than 2 minutes to download the edge version, which is slightly bigger (427Mb) than the stable (374Mb).
  • Once downloaded, double-click Docker Desktop Installer executable to run the installer. If you are running a supported system, Docker Desktop prompts you to enable WSL 2 during installation. Read the information displayed on the screen and enable WSL 2 to continue.
  • Open a command-line terminal like PowerShell or the very cool Windows Terminal, which I strongly recommend due to its flexibility and versatility, and try out some Docker commands.
    • Run docker version to check the version. You should see something like this.
WindowsTerminalDockerVersion
    • Run docker run hello-world to verify that Docker can pull and run images and run the docker container. You should see the downloaded hello-world image like this.
WindowsTerminalHelloWorld
    • Run docker images hello-world. To see all docker images run docker images.
WindowsTerminalDockerImageHW

WSL2

You might have heard about WSL2! It is the second and better version of WSL (Windows Subsystem for Linux). The Windows Subsystem for Linux lets developers run a GNU/Linux environment — including most command-line tools, utilities, and applications — directly on Windows, unmodified, without the overhead of a traditional virtual machine or a dual-boot setup.

WSL2’s primary goals are to increase file system performance, as well as adding full system call compatibility

That’s excellent news for those who love working with Linux and lots of other freelancer developers who need to have multiple operating systems in their machines. Not to mention the fact that Linux and Windows are the most popular among developers, according to Stack Overflow’s last survey conducted in 2018.

Install the Windows Subsystem for Linux

The next steps are available in the official Windows Subsystem for Linux Installation Guide for Windows 10. Still, we are not installing version 1 of WSL, so that you can follow here for better convenience.

Pre-requisites to install WSL2:

  • Running Windows 10, updated to version 1903 or higher, Build 18362 or higher for x64 systems.
  • Running Windows 10, updated to version 2004 or higher, build 19041, for ARM64 systems.
  • Please note if you are on Windows 10 version 1903 or 1909, you will need to ensure that you have the proper backport; instructions can be found here.
  • Check your Windows version by selecting the Windows logo key + R, type winver, choose OK. (Or enter the ver command in Windows Command Prompt). Please update to the latest Windows version if your build is lower than 18361. Get Windows Update Assistant.

Before installing any Linux distributions on Windows, you must enable the “Windows Subsystem for Linux” optional feature.

Open PowerShell or Windows Terminal as Administrator and run:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Before installing WSL 2, you must enable the “Virtual Machine Platform” optional feature.

Open PowerShell or Windows Terminal as Administrator and run:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Restart your machine to complete the WSL 2 install.

Open PowerShell or Windows Terminal as Administrator and run this command to set WSL 2 as the default version when installing a new Linux distribution:

wsl --set-default-version 2

Install your Linux distribution of choice

Microsoft Store - Ubuntu

The following links will open the Microsoft store page for each distribution:

  • From the distribution’s page, click on Get.

Set up a new distribution

The first time you launch a newly installed Linux distribution, a console window will open, and you’ll be asked to wait for a minute or two for files to de-compress and be stored on your PC. All future launches should take less than a second.

You will then need to create a user account and password for your new Linux distribution.

Ubuntu setup

Congratulations, you made it! You’ve just successfully started the first of 4 steps journey to have a great, flexible, versatile and tidy development environment.

Furthermore, at the end of this series, you will be able to run hybrid containerized apps in your software development environment. Maintain, test and deploy using databases, more than one operating system and web servers in your machine effortlessly with the docker container concept.

Besides having all local development and deployment process covered in a rich cross-platform, you will be able to work with distributed applications, cloud environments, DevOps teams, other team members or even other development teams efficiently.

Docker came to replace conventional virtual machines as we know them, and it’s the base to automate the deployment efficiently of the modern cloud computing environment. Furthermore, enterprise software must respond quickly to changing conditions. That means both easy scalings to achieve demand and easy updating to add new features as the business demands.

Docker containers make it easy to introduce new versions of software, with new features, into production quickly – and to quickly roll back to a previous version if it is necessary. They also make it possible and easier to implement strategies like blue/green deployments.

Instances of containerized apps use much less memory than virtual machines, they start up and stop far more quickly, and they can be packed more densely on their host hardware environment. All of this amounts to less spending on the Information Technology department.

Do you want to know more about us and our mission? Click here, and don’t forget to subscribe!

We also have pro bono projects just in case you are interested in learning more about them.

Be aware of why we started this project by clicking here.

Learn more about other posts here.

Contact us for any suggestions. And follow us on Facebook, Instagram and Twitter.

If you are a good reader like myself, I recommend the following readings:

  • Docker Quick Start Guide: Learn Docker like a boss, and finally own your applications
  • Docker for Developers: Develop and run your application with Docker containers using DevOps tools for continuous delivery

See you in the next post!

%d bloggers like this: