Before the Docker series: Why is a Linux environment necessary?

Before starting the Docker series, I need to talk about something super important.
Developers can access the power of both Windows and Linux simultaneously on a Windows machine.
Why is Linux necessary? The answer is simple.
99% of production servers are Linux.
AWS EC2 → Linux
Google Cloud Compute Engine → Linux
Azure VM → Linux (there is Windows, but it's the minority)
Shared hosting → Linux
Docker → Linux
Kubernetes → Linux
In other words, if you want to match your development environment with your production environment, you should develop on Linux.
But there is a problem:
Developers using Windows → The OS is different
Developers using Mac → It's UNIX-based, but strictly speaking, it's not Linux
The solution to this problem is WSL2 (on the Windows side) and the corresponding approach for Mac.
What is WSL2? The magic of running Linux on Windows
The Windows Subsystem for Linux (WSL) lets developers install a Linux distribution (such as Ubuntu, OpenSUSE, Kali, Debian, Arch Linux, etc.) and use Linux applications, utilities, and Bash command-line tools directly on Windows, unmodified, without the overhead of a traditional virtual machine or dual-boot setup.
To put it simply:
WSL2 = Real Linux running inside Windows. And it's super lightweight.
WSL1 vs WSL2: What's the difference?WSL 1 operated as a compatibility layer that emulated Linux system calls, whereas WSL 2 introduced an actual Linux kernel.
WSL1 (Legacy):
Translates Linux system calls to run on Windows
Compatibility issues
Slow
Released in 2016
WSL2 (Current):
Equipped with a real Linux kernel
Full Linux compatibility
File access up to 20x faster
Runs on a lightweight virtual machine (Hyper-V)
Released in 2020
Conclusion: WSL2 is the only choice. Forget WSL1.
How WSL2 worksWindows 11/10
└─ Hyper-V(軽量仮想マシン)
└─ 本物のLinuxカーネル
└─ Ubuntuなどのディストリビューション
└─ あなたのアプリ
It's a virtual machine, but unlike traditional VMs:
Super fast startup (a few seconds)
Dynamic memory usage (uses only what is needed)
Easy file sharing between Windows and Linux
Network sharing between Windows and Linux
[For Windows Users] WSL2 Installation Steps
PrerequisitesYou must be running Windows 10 version 2004 or higher (build 19041 or higher) or Windows 11.
How to check:
Win + R → type winver → Enter
Check the version number
If it is an older version, update to the latest via Windows Update.
Step 1: WSL2 Installation (Super Easy)Open PowerShell with administrator privileges:
Start menu
Type "PowerShell"
Right-click → "Run as administrator"
Complete in just one line:
wsl --install
This command enables all features necessary to run WSL and installs a Linux distribution (Ubuntu).
When executed:
WSL2 features are enabled
Virtual Machine Platform is enabled
Ubuntu is installed
Restart is required
Restart your computer.
Step 2: Initial SetupAfter restarting, launch "Ubuntu" from the Start menu.
On first launch:
Installing, this may take a few minutes... Please create a default UNIX user account. The username does not need to match your Windows username. For more information visit: https://aka.ms/wslusers Enter new UNIX username: yourname New password: Retype new password:
Set your username and password.
Note: Nothing will be displayed on the screen when entering your password. This is normal behavior. Type it and press Enter.
Once complete:
yourname@DESKTOP-XXXXX:~$
Congratulations, Linux is running.
Step 3: Version CheckIn a separate PowerShell window:
# インストール済みディストリビューション確認 wsl --list --verbose 出力例 NAME STATE VERSION * Ubuntu Running 2
If VERSION is 2, you are good to go.
Step 4: Update Ubuntu to the latest versionInside Ubuntu:
# パッケージリスト更新 sudo apt update パッケージアップグレード sudo apt upgrade -y
Now your latest Ubuntu environment is ready.
Frequently used WSL2 commands
# WSL2起動(デフォルトディストリビューション) wsl 特定のディストリビューション起動 wsl -d Ubuntu インストール済み一覧 wsl --list --verbose WSL2シャットダウン wsl --shutdown 特定のディストリビューション停止 wsl --terminate Ubuntu ディストリビューション削除 wsl --unregister Ubuntu 他のディストリビューションをインストール wsl --install -d Debian wsl --install -d Kali-Linux
File sharing with Windows
This is extremely convenient.
Accessing Linux files from WindowsIn the File Explorer address bar, type:
\\wsl$\Ubuntu\home\yourname
You can see your Linux home directory.
Alternatively, "Linux" appears in the File Explorer sidebar. Just click it.
Accessing Windows files from LinuxInside Ubuntu:
# Cドライブ cd /mnt/c/ ユーザーフォルダ cd /mnt/c/Users/YourWindowsUsername/ デスクトップ cd /mnt/c/Users/YourWindowsUsername/Desktop/
All Windows drives are mounted under /mnt/.
Integration of VS Code and WSL2
This is seriously convenient.
Install extensionSearch for "WSL" in VS Code → Install "Remote - WSL".
Launch VS Code within WSL2Inside Ubuntu:
cd ~/myproject code .
VS Code launches in WSL2 mode. The editor is Windows, the execution environment is Linux. Perfect.
If "WSL: Ubuntu" is displayed in the bottom left, you have succeeded.
[For Mac users] Creating an environment equivalent to WSL2
Mac users cannot use WSL2. But that is okay.
Current state of Mac: Already a Unix environmentMac is a Unix-based OS (BSD-based). If you open the terminal:
# Mac標準でUnixコマンドが使える ls pwd grep awk
However, strictly speaking, it is not Linux.
Mac (BSD-based) vs Linux:
Package managers are different (Homebrew and apt)
Some command options are different
System libraries are different
The kernels are different
It's sufficient as a development environment, but if you want it to match your production server exactly, you need Linux.
Option 1: Use Docker (Recommended)This is the best solution.
If you use Docker, Linux containers will run on your Mac.
# Ubuntu 22.04コンテナ起動 docker run -it ubuntu:22.04 /bin/bash これでLinux環境 root@abc123:/# apt update root@abc123:/# apt install python3
I will explain this in detail in the Docker series.
Option 2: Lima (Lightweight VM)Lighter than Docker and provides an experience close to WSL2.
Installation:
brew install lima
Starting Ubuntu:
# デフォルトVM作成・起動 limactl start VM内に入る lima これでLinux環境 yourname@lima-default:~$
Lima features:
Runs a Linux kernel
Easy file sharing
Supports Docker and Kubernetes
Lighter than WSL2
Created by the developers of Ubuntu.
Installation:
brew install --cask multipass
Starting Ubuntu:
# インスタンス作成 multipass launch --name dev 接続 multipass shell dev これでUbuntu環境 ubuntu@dev:~$
For Apple Silicon (M1/M2/M3), UTM is lightweight.
Install "UTM" from the App Store. You can create VMs with a GUI.
Which one should I use?Use Case Recommendation Planning to use Docker Docker is the only choice Lightweight development environment Lima Prefer official Ubuntu Multipass Want to manage with GUI UTM Mac terminal is enough Use it as is
My recommendation: Lima.
Reasons:
Lightweight
Close to WSL2
Runs Docker too
One-shot install with Homebrew
Creating the same environment on Windows (WSL2) and Mac
This is the goal.
Scenario: Team developmentPerson A: Windows + WSL2 (Ubuntu 22.04)
Person B: Mac + Lima (Ubuntu 22.04)
Production server: AWS EC2 (Ubuntu 22.04)
Everyone develops on Ubuntu 22.04.
Steps for environment unification1. Use the same Ubuntu version
Windows (WSL2):
wsl --install -d Ubuntu-22.04
Mac (Lima):
# lima.yaml作成 limactl start --name=dev template://ubuntu-22.04 接続 lima dev
2. Install the same packages
Create setup.sh:
#!/bin/bash
setup.sh - 環境セットアップスクリプト
システム更新
sudo apt update
sudo apt upgrade -y
基本ツール
sudo apt install -y \
build-essential \
git \
curl \
wget \
vim
Python 3.11
sudo apt install -y python3.11 python3.11-venv python3-pip
Node.js
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
echo "セットアップ完了!"
How to use:
# Windows(WSL2)でも、Mac(Lima)でも同じ bash setup.sh
With this, everyone has the same environment.
3. Complete unification with Docker (The best way)
If you use Docker, you don't even need to worry about the OS.
# Dockerfile
FROM ubuntu:22.04
RUN apt update && apt install -y \
python3.11 \
python3-pip \
nodejs \
npm
WORKDIR /app
COPY . /app
CMD ["bash"]
# Windows・Mac・Linux、どこでも同じ docker build -t myenv . docker run -it myenv
In this case, neither WSL2 nor Lima is necessary. You can unify everything using only Docker.
Common pitfalls and solutions
[Windows] Case 1: "WSL2 is not enabled"Cause: Virtualization is disabled, or BIOS settings
Solution:
Enable virtualization (VT-x/AMD-V) in BIOS
Run again in PowerShell:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Restart
Limit WSL2 memory usage.
Solution: Create C:\Users\YourName\.wslconfig:
[wsl2] memory=4GB processors=2 swap=2GB
Restart WSL2:
wsl --shutdown
Cause: It is slow to cross between the Windows file system and the Linux file system
Solution: Place projects on the Linux side (~/). Avoid the Windows side (/mnt/c/).
# ❌ 遅い cd /mnt/c/Users/YourName/project ✅ 速い cd ~/project
Cause: Homebrew version is outdated
Solution:
brew update brew upgrade lima
If using Docker within Lima:
# Docker対応テンプレートで起動 limactl start --name=docker template://docker これでDocker使える lima docker ps
Cause: Package list is outdated
Solution:
sudo apt update sudo apt install <package>
Next time: Docker Practice
The Linux environment is now set up with WSL2 (or Lima).
Next time is the second installment of the Docker series: Docker Practice
Installing Docker Desktop (supports both Windows/Mac)
Integrating WSL2/Lima with Docker
Starting your first container
How to write a Dockerfile
Running an actual app with Docker
Get hands-on and learn by doing.
Summary: The same Linux environment on Windows and Mac
Read this far, just remember this:
✅ Production servers are Linux → Development environments should also be unified with Linux
✅ WSL2 = Real Linux running inside Windows
✅ Mac → You can create a Linux environment with Lima, Multipass, or UTM
✅ The ultimate solution is Docker (details next time)
✅ Both WSL2 and Lima work perfectly with Docker
The 3 Principles of Environment Unification:
Use the same OS version (e.g., Ubuntu 22.04)
Automate with setup scripts
Complete unification with Docker is the best
"It works on my machine..." "The behavior is different between Windows and Mac..." "It doesn't work in production..."
This nightmare is over.
Unify your development environment with WSL2 (or Lima). Furthermore, if you use Docker, it's perfect.
Next time, we will dive into Docker in practice.
Are you ready?
Reference links:
WSL Official Documentation: https://learn.microsoft.com/ja-jp/windows/wsl/
WSL Installation: https://learn.microsoft.com/ja-jp/windows/wsl/install
Lima GitHub: https://github.com/lima-vm/lima
Multipass Official: https://multipass.run/
UTM: https://mac.getutm.app/
Docker Official: https://www.docker.com/