Deploy Linux & Docker/Portainer
If you’re a beginner to linux and docker/microservices, this how-to is a great starting point. This approach creates a clean canvas to deploy our AI tools in a modular and easily maintainable manner. We’ll get to the actual AI stuff soon.
If you already have a linux workstation (bare metal or hypervisor-based VM), you can skip this step. If you’re a Windows user, we’ll deploy linux via WSL2.
Why WSL 2?
Section titled “Why WSL 2?”- Native-speed Linux kernel on Windows
- Shared file system with Windows (
\\wsl$
) - no clunky dual-boot - Perfect runtime for Docker without Virtual Machine overhead
Note: WSL 2 needs Windows 10 21H2+ or Windows 11.
Step 1 — Install WSL 2 + Ubuntu
Section titled “Step 1 — Install WSL 2 + Ubuntu”-
Open PowerShell as Administrator and run the single command:
Terminal window wsl --installThis:
- enables all pre-requiste Windows Subsystem for Linux features
- downloads latest Ubuntu LTS (as of now version 24.04)
- sets Ubuntu LTS as the default WSL 2 version
-
Create your Linux username/password.
That’s it. After you set your password you’ll be in your WSL2 linux environment. Use your search bar and search for “Ubuntu” to open a new terminal session at any time.
Step 2 — Install Docker inside WSL 2
Section titled “Step 2 — Install Docker inside WSL 2”We’re going to deploy the latest version of docker and use portainer as our container orchestrator and front-end.
- Set up Docker’s apt repository.
# inside the Ubuntu shell# Add Docker's official GPG key:sudo apt updatesudo apt install ca-certificates curlsudo install -m 0755 -d /etc/apt/keyringssudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.ascsudo chmod a+r /etc/apt/keyrings/docker.asc# Add the repository to Apt sources:echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullsudo apt update
- Install the latest Docker packages
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Step 3 — Deploy Portainer with Docker Compose
Section titled “Step 3 — Deploy Portainer with Docker Compose”Portainer gives us a browser dashboard to launch / monitor / troubleshoot containers and stacks.
We’ll be using the stacks feature to organize and manage our containers in later lessons. For now, let’s just get portainer running.
-
Create 2 new folders - a docker folder for our docker-compose file, & a portainer folder to mount portainer data to our host:
Terminal window mkdir -p ~/docker/portainer -
Add a
docker-compose.yml
:
Inside the docker
directory, create a new file with the command nano docker-compose.yml
.
Add the following contents -
services: portainer: image: portainer/portainer-ce:latest container_name: portainer restart: always ports: - "8000:8000" # Edge agent (optional) - "9443:9443" # HTTPS UI/API volumes: - /var/run/docker.sock:/var/run/docker.sock - ~/docker/portainer:/data
ctrl + x to exit the nano editor & Y to save our new file changes.
- going forward, I’ll assume you know how to make and edit files in linux.
-
Launch it:
Terminal window sudo docker compose up -dsudo docker ps
You should see the portainer/portainer-ce:latest
image listed with a up
status.
- Open https://localhost:9443 (enter an admin password on first run).
After setting a password, you’re greeted with the portainer dashboard. Click “containers” to see the status of your newly created container.
Great, now we’ve created the canvas for our AI productivity environment.
What’s next?
Section titled “What’s next?”Part 2 will show you how to:
- spin up LLM API using docker containers (Ollama + OpenWebUI) inside WSL 2 visually through Portainer Stacks.
Quick recap
Section titled “Quick recap”We did | Why it matters |
---|---|
Installed WSL 2 | Performant Linux Dev Environment Integrated with Windows |
Installed Docker Engine | Containerization Backbone |
Deployed Portainer | Visual Docker Container Management & Orchestration |