Docker container: Next Big Thing in Software Development 1/4
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.
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 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.
- 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 Installerexecutable 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.
docker versionto check the version. You should see something like this.
docker run hello-worldto verify that Docker can pull and run images and run the docker container. You should see the downloaded hello-world image like this.
docker images hello-world. To see all docker images run
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
vercommand 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
- Open the Microsoft Store and select your favourite Linux distribution.
The following links will open the Microsoft store page for each distribution:
- Ubuntu 16.04 LTS
- Ubuntu 18.04 LTS
- Ubuntu 20.04 LTS
- openSUSE Leap 15.1
- SUSE Linux Enterprise Server 12 SP5
- SUSE Linux Enterprise Server 15 SP1
- Kali Linux
- Debian GNU/Linux
- Fedora Remix for WSL
- Pengwin Enterprise
- Alpine WSL
- 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.
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.
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!