Essential Cloud Development Tools for Windows 10 Users

Standard

The combination of Docker Desktop, Windows Subsystem for Linux (WSL), and Visual Studio Code with extensions is extremely powerful!

I seen that a lot of software developers use Mac, and I’ve used Macs too. However now that Microsoft has a focus on open source, everything has changed. Windows 10 can leverage many Linux distros with the WSL. Using PowerShell and the Bash Shell natively is amazing. We will still leverage virtualization on Windows utilizing Hyper-V for Linux Docker containers, however we can still use the WSL with Docker Desktop. There’s extra configuration needed to make it work. This is due to limitations of WSL not being able to run daemons as a service. Regardless this is the best development experience I’ve seen as I can run locally just as easily as in the cloud and I know though my testing it’ll work the same. The portability of containers solves a lot of challenges.

Here I’ll show you the essentials of preparing your Windows 10 computer for modern applications development in the cloud.

Windows Subsystem for Linux

https://docs.microsoft.com/en-us/windows/wsl/install-win10

Follow Microsoft’s documentation to enable the WSL. I recommend you install the “Bash on Ubuntu on Windows” environment. There’s some key points you need to understand specific to Ubuntu on Windows.

  • Windows disks are available via mount points, for example /mnt/c
  • chmod permissions won’t work on files mounted in NTFS disks
  • WSL uses a special LXFS for file system compatibility
  • Linux services cannot be autostarted
  • SystemD has limitations
  • Applications cannot run in the foreground

For this reason you cannot run Docker CE server within WSL. However you can use the WSL with the Docker client to connect to Docker Desktop running on Windows with Hyper-V.

Docker Desktop on Windows

https://hub.docker.com/editions/community/docker-ce-desktop-windows

Follow Docker’s documentation to install Docker Desktop. You can alternate between Windows and Linux containers, choose Linux containers. It’s best if you install Docker Desktop on a computer with virtualization technology enabled in the BIOS and Hyper-V enabled in Windows. This option will provide you the best performance for running Linux Docker containers on Windows as it’ll run on the native hypervisor versus VirtualBox which uses software emulation for hardware.

Docker CE on Ubuntu WSL

https://docs.docker.com/install/linux/docker-ce/ubuntu/

Follow Docker’s documentation to install Docker CE on Ubuntu. In this case you’re installing Docker into the Ubuntu WSL. However, since we cannot run the Docker daemon within WSL we’ll be utilizing the Docker client which will be installed as part of this process.

To connect the Docker client in WSL to Docker Desktop we’re going to expose the Docker Desktop daemon without TLS. I’ve tried unsuccessfully to connect the Docker client in WSL to Docker Desktop using TLS. Instead I’ve enabled exposing the daemon without TLS and created a firewall rule on my local host to deny requests on 2375 outside of the local host.

Right-click on the Docker Desktop icon in your tray > Settings > General

Next in Ubuntu WSL console run the following to add an environment variable the Docker client uses to connect to a Docker server. The second commands removes the variable for the Docker client to verify TLS.

echo "export DOCKER_HOST=tcp://localhost:2375" >> ~/.bashrc
echo "unset DOCKER_TLS_VERIFY" >> ~/.bashrc
source ~/.bashrc

At this point if you check the “docker version” you should see both the client and server.

Visual Studio Code and the WSL Terminal

In Visual Studio Code there’s a built in terminal for PowerShell and WSL. You can use them both at the same time even with a split terminal view. Having a Bash on Ubuntu terminal directly within the IDE is extremely powerful. Especially combined with the Docker extensions, AWS Toolkit, AWS SAM, and many others. This way I’m doing everything local yet using the same commands and tools I would on a Linux server.

A really nice feature is being able to right-click on the Dockerfile and click build image. A popup at the top of the screen will ask you for an image tag. Provide a tag then hit enter and Visual Studio Code will open a WSL terminal and execute the command create a container image.

As you do your development work and you’re wanting to test your apps in a container you can do this directly within Visual Studio Code. Using Docker Explorer in Visual Studio Code you can run your containers interactively simply by right-clicking and select run interactive.

 

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.