Containers, containers everywhere...

Table of Contents

Why bother

Mostly as a self-challenge to get exposure and some hands on with technology that I don't get to work with (yet) and as a preamble to a subsequent post on deploying and running containers in the cloud. I won't get into why you'd want to deploy containers since a quick google search will pull up a myriad of results on their benefits and use cases.Β 

Arm yourself with:

In Order of Operations:

Enable WSL and whatever Linux distro MS offers for WSL:

wsl --set-default-version 2
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
The operation completed successfully.

If you've already enabled WSL and installed your distro of choice (my preference is Debian) you'll need to upgrade it from WSL 1 to WSL 2:

wsl --set-version Debian 2

Things that will test your patience:

Virtualization not enabled in BIOS

If you don't have virtualization enabled in BIOS, close your 5 browser windows with 20+ tabs each and reboot so you can enable it.Β 

Need to enable WSL

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
If you prefer enabling it via the GUI:

Docker command not in PATH

Typing docker will result in:

The term 'docker' is not recognized as a name of a cmdlet, function, script file, or executable program.Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Go ahead and add the C:\Program Files\Docker\Docker\resources\binlocation to the PATH environment variable.

Docker WSL integration

For Docker to recognize that you have WSL installed, it needs to be of the WSL 2 variety.

Port conflict

If you already have something running on port 80, and if you follow the extremely well written Docker Getting Started guide (whoever wrote it deserves a huge raise), you will run into the inability to launch the container since it will try to bind to port 80.
The way to overcome it is to either kill whatever is running on that port, or to map a different port like so:Β 

docker ps
CONTAINER ID   IMAGE                           COMMAND                  CREATED        STATUS        PORTS                NAMES
6d34b2c77283   docker/getting-started:latest   "/docker-entrypoint.…"   41 hours ago   Up 41 hours   0.0.0.0:81->80/tcp   happy_chandrasekhar

Useful commands:

docker ps- lists all running images

docker ps -a- lists all images, regardless of stateΒ 

docker run -dp 81:80 <name of container>- maps port 80 in the container to port 81 on the host (avoiding any port conflict you may have due to a service running on port 80) and runs the container in a detached mode.Β 

Additional Resources: