image Modify YML files with PowerShell image QA Toolkit part 1

Running development tools and applications in Docker on Windows 10

Windows Subsystem for Linux 2 (WSL2) brought some fresh air to the Windows 10 operating system. Before WSL1, we had to have a separate virtual machine or dual boot to develop applications that were necessary to run on Linux. In some cases, the development process was just easier under Linux. Ten years ago I was developing applications with Ruby on Rails and I remember it was tricky to install the tools and run the code on Windows. That’s why I was using Ubuntu Linux for years and loved the experience.

In the last couple of years, I am working mostly with Microsoft .NET and using many open source applications, tools, and databases to get the work done. That means installing all sorts of database technologies, monitoring tools, messaging infrastructure, frameworks, tools, etc. And those apps are hungry for resources and install a lot of libraries and tools that can clog up the system in the long run. At least that’s my experience with the Microsoft ecosystem.

Recently I was re-installing my desktop PC to Windows 10 (2004) and wondered how I could improve that. With a fresh system, there is no better time to do it. Many tools I use run on Linux and are nowadays containerized and can be run with Docker. For some time now you could run Linux Docker containers inside Windows 10, but the latest Windows update supports WSL2, which is faster and more optimized.

Running docker containers is great, but the real magic lies in a Docker compose scripts. With those, you can easily spin up multiple containers at once, so for example, if you need a database and a client of some sort, you can compose them and run them together. In the end, I prepared basic docker-compose files for these tools:

  • Microsoft SQL server
  • MySQL
  • PostgreSQL
  • RabbitMQ
  • Grafana
  • Prometheus
  • Nginx
  • InfluxDB
  • MongoDB
  • Redis

For every application, there are three parts: docker-compose file, variables file, and a runner script. First, let me show you a Docker compose file for SQL Server 2019. Every docker image can have several environment variables you can find about those for every image in DockerHub. In the case of SQL Server 2019, we need to specify the SA password, ProductID and we need to accept EULA automatically. Next, if you want the state to persist you need to mount a volume (which is something you want to do for a database). We also need to publish a port and specify a docker image. Save the below docker-compose file to docker-compose.yml and continue.

As you can see, there are some properties that have variable placeholders (${…}), which will be specified in the file:

Save the variables to the sqlserver.env file to the same folder as docker-compose.yml.

The final piece is a runner script. As a command argument, you need to specify a docker-compose and variable file:

If everything is setup correctly you should see SQL server starting:

And that’s it! Now you can run SQL Server 2019 on demand and save local resources :).

What’s next?

To extend this further, you could create docker-compose Powershell scripts, add those to the Windows 10 PATH ENV variable and run them from the Windows Terminal with Powershell Core.

The solution above keeps resources on Windows 10 under control. No more unnecessary services and applications that run all the time. This saves CPU, memory, and storage.

I’ve put those scripts on the Github. I’ll improve them in the future, so be sure to check the GIT repository from time to time :).

Let me know what you think in the comments below or contact me through LinkedIn!

About Miha
I've always been fascinated by computers. I am happy that I can work in this creative field of software development, where I can solve problems. I am also an avid cyclist :) and I love to learn...a lot!
Related Posts
  • All
  • By Author
  • By Category

Leave a Reply