Jump to content

Docker Setup Win and Linux 260203

From Game in the Brain Wiki

Docker Setup Wiki: Windows & Ubuntu 24.04

1. The Concept: "Appifying" Your System

Docker solves the classic "it works on my machine" problem.

"Appification": Think of Docker as "Appifying" a server application. Instead of installing a messy web of dependencies (Python versions, specific libraries, configurations) directly onto your computer, you download a Container. This container holds the app and its entire environment inside a sealed box.

Write Once, Run Anywhere: Because the container has everything it needs inside, it runs exactly the same on a high-end Windows gaming PC, a MacBook, or a Linux server. The host operating system doesn't matter; it just needs to run Docker.

Docker vs. Virtual Machines (VMs):

    • VMs are heavy. They require a full separate Operating System (OS) for every app, "locking" chunks of your RAM and CPU even when idle.
    • Docker is efficient. Containers share your system's resources (kernel) dynamically. If a container isn't doing work, it's not eating up your CPU.

2. Windows Tutorial (Docker Desktop)

Windows is the easiest entry point because Docker Desktop handles the complex Linux backend (WSL2) for you invisible.

Installation

Download Docker Desktop for Windows from docs.docker.com.

Run the installer. Ensure "Use WSL 2 instead of Hyper-V" is checked (this is much faster).

Restart your computer.

The "Marketplace" Workflow

Docker Desktop feels like an App Store for server software.

Open Docker Desktop.

In the top search bar, type what you want (e.g., postgres, nginx, or minecraft).

Click Pull to download the "App" (Image).

Go to the Images tab, find what you downloaded, and click the Run (Play) button.

It will ask for optional settings (ports, volumes) and then launch.

Using the Command Line (PowerShell)

You can also run it purely via text, exactly like on Linux. Open PowerShell and try:

Run a "Hello World" container to test

docker run hello-world

Run an Nginx web server on port 8080

docker run -d -p 8080:80 nginx

3. Ubuntu 24.04 (Noble Numbat) Tutorial

For Linux, we install the Docker Engine directly. These commands are pulled from the official documentation but simplified for an end-to-end flow.

Step 1: Install Docker Engine

Open your terminal and run these commands block by block:

A. Set up Docker's apt repository:

1. Update apt and install packages to allow apt to use a repository over HTTPS

sudo apt-get update
sudo apt-get install ca-certificates curl

2. Create the directory for keys

sudo install -m 0755 -d /etc/apt/keyrings

3. Download Docker's official GPG key

sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

4. 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/null

5. Update apt again to see the new repo

sudo apt-get update

B. Install the Docker packages:

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Step 2: The "Easy" Fix (Post-Installation)

By default, you have to type sudo for every Docker command. Let's fix that so it acts like an easy app.

Add your current user to the docker group

sudo usermod -aG docker $USER

APPLY the change immediately (or just reboot)

newgrp docker

Step 3: GUI Tracking with Gnome Extensions

To easily track your running containers without using the terminal constantly, use a Gnome Extension.

Install the Extension: Go to the Gnome Extensions website.

Search for Easy Docker Containers.

    • Identifier: easy_docker_containers@red.software.systems

Toggle the switch to ON to install.

Result: You will now see a Docker icon in your top system bar. Clicking it shows a list of running containers, allowing you to Start/Stop/Restart them visually.

4. Portainer CE (The Ultimate GUI)

For a full "Command Center" experience on Ubuntu (or Windows), install Portainer. It gives you a web dashboard to manage everything.

Installation

Run this single command block to create a data volume and start Portainer:

Create a volume so Portainer doesn't lose data

docker volume create portainer_data

Run Portainer

docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

How to Access

Open your web browser (Firefox/Chrome).

Go to: https://localhost:9443

Note: You will get a "Security Warning" because it uses a self-signed certificate. Click Advanced -> Accept the Risk/Proceed.

Create your admin password and select Get Started with the local environment.

5. Common Examples

You can find a list of common, useful Dockers at wiki.gi7b.org.

Example: Minecraft Server

This is a classic example of "Appifying" a system. Instead of installing Java, downloading Jars, and editing text files, you just run this command.

The Command (Java Edition):

docker run -d -it -p 25565:25565 -e EULA=TRUE --name mc-server itzg/minecraft-server

itzg/minecraft-server: The name of the image (the "App").

-e EULA=TRUE: Accepts the license agreement automatically.

-p 25565:25565: Opens the game port so you can connect.

Appendix: Applications for Students & The GUI Philosophy

Why GUI? (Visual Context vs. Memorization)

For students and professionals with busy lives, memorizing hundreds of command-line functions is not economical. The goal of modern computing is to build visual context.

Intuitive Workflow: We grew up with graphical interfaces (buttons, windows, menus). Tools like Portainer and Docker Desktop bridge the gap, allowing you to manage complex server infrastructure using the same point-and-click logic you use for a web browser or smartphone.

Visual Management: Instead of typing docker ps to see what's running, you look at a dashboard. If a container is green, it's running; if it's red, it's stopped. This visual feedback loop is faster and less prone to error.

Docker: Making Services "Browser-Native"

Most Docker containers act as local web services.

You run the container (e.g., a Jupyter Notebook or a WordPress site).

You open your browser and type localhost:8080.

The application runs entirely inside the browser window.

The Ultimate Student Project: "Dockerize" Your Product

If you are building a project for school or a startup:

Don't send a zip file with instructions like "install Python 3.9, then pip install pandas, then set this path..."

Create a Docker Image.

The Promise: If your professor or investor has Docker installed (which they will, if they followed this guide), they just run one command. Your product launches exactly as you designed it, running perfectly on their Windows, Linux, or Mac machine.