Skip to content

Repository files navigation

Docker for Android CI — From Zero to Emulator

A hands-on workshop that teaches Docker from scratch by building a real-world project: a Docker image for Android CI/CD that supports building, testing, linting, and running instrumented tests with an emulator.

Who Is This For?

  • Docker beginners who learn best by building something practical
  • Android developers who want to containerize their CI pipeline
  • DevOps engineers looking to create reproducible Android build environments

No prior Docker experience required. Basic command-line familiarity is assumed.

What You'll Build

By the end of this workshop, you'll have a production-ready Docker image that can:

  • Compile Android apps (APK/AAB)
  • Run JVM unit tests
  • Run lint and static analysis
  • Run instrumented tests via a headless Android emulator
  • Integrate with any CI system (GitHub Actions, GitLab CI, Jenkins, etc.)

Workshop Modules

# Module Key Concepts
1 Docker Fundamentals Images, containers, basic commands
2 Your First Dockerfile FROM, RUN, COPY, layers, caching
3 Installing the Android SDK SDK tools, environment variables
4 Building an Android App Volumes, Gradle, build artifacts
5 Unit Tests & Static Analysis ARG/ENV, entrypoint scripts
6 Android Emulator Headless emulator, health checks
7 Optimization & Best Practices Multi-stage builds, security
8 Docker Compose & CI Integration Compose, GitHub Actions, GitLab CI

Each module builds on the previous one. Work through them in order.

Prerequisites

Install Docker

macOS
  1. Download and install Docker Desktop for Mac
    • Choose Apple Silicon (M1/M2/M3/M4) or Intel depending on your Mac
  2. Open Docker Desktop and complete the setup wizard
  3. Verify installation:
    docker --version
    docker run hello-world

Notes:

  • Docker Desktop for Mac uses a lightweight Linux VM under the hood (via Apple's Virtualization framework or QEMU)
  • The Android emulator module (Module 6) has limitations on macOS — KVM is not available, so emulator performance will be slower. For production CI, use a Linux host.
  • Minimum 8 GB RAM recommended (16 GB preferred for emulator work)
Linux (Ubuntu/Debian)

Option A — Docker Engine (recommended for servers and CI):

# Remove old versions
sudo apt-get remove docker docker-engine docker.io containerd runc

# Install via official script
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

# Add your user to the docker group (avoids needing sudo)
sudo usermod -aG docker $USER
newgrp docker

# Verify
docker --version
docker run hello-world

Option B — Docker Desktop for Linux (GUI, similar to macOS/Windows):

Notes:

  • Linux is the ideal platform for this workshop — full KVM support for the Android emulator
  • Ensure KVM is available: ls /dev/kvm (for Module 6)
  • If KVM is missing, enable virtualization in your BIOS/UEFI settings
Windows
  1. Ensure WSL2 is installed and enabled:

    wsl --install

    Restart if prompted, then set WSL2 as default:

    wsl --set-default-version 2
  2. Download and install Docker Desktop for Windows

    • During setup, ensure "Use WSL 2 based engine" is checked
  3. Open Docker Desktop, go to Settings > General, and confirm WSL2 is enabled

  4. Verify in a terminal (PowerShell, CMD, or WSL2 bash):

    docker --version
    docker run hello-world

Notes:

  • All workshop commands use Unix/bash syntax. On Windows, run them inside WSL2 (e.g., Ubuntu from the Microsoft Store) or Git Bash for the best experience.
  • The Android emulator module (Module 6) requires nested virtualization. It works on WSL2 if Hyper-V is enabled, but performance is limited compared to a native Linux host.
  • Minimum 8 GB RAM, 16 GB recommended

Other Requirements

  • Disk space: ~15-20 GB free (Android SDK + emulator system images are large)
  • Internet connection: Required for downloading Docker images and SDK components
  • Text editor: Any editor you're comfortable with (VS Code recommended)

Platform Differences Cheat Sheet

Throughout the workshop, most commands are identical across platforms. Here are the key differences:

Task macOS / Linux Windows (WSL2 / Git Bash)
File paths in -v mounts /home/user/project /mnt/c/Users/user/project or /c/Users/user/project
Line endings LF (default) Configure Git: git config --global core.autocrlf input
KVM for emulator --device /dev/kvm (Linux only) Not available natively
Shell scripts Work directly Ensure LF line endings (not CRLF)
Docker socket /var/run/docker.sock Same path inside WSL2

Important for Windows users: Before cloning this repo, configure Git to use LF line endings:

git config --global core.autocrlf input

This prevents shell scripts from breaking due to Windows CRLF line endings.

How to Use This Workshop

  1. Read the module README — understand the concepts before typing commands
  2. Type the commands yourself — don't just copy-paste; muscle memory helps learning
  3. Do the exercises — they reinforce what you learned
  4. Experiment — break things on purpose, change values, see what happens
  5. Ask questions — if something doesn't make sense, dig into it

Quick Start

# Clone this repo
git clone https://github.com/Njko/learning_docker.git
cd learning_docker

# Start with Module 1
cd module-01-fundamentals
# Open README.md and follow along

Ready? Start with Module 1: Docker Fundamentals.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages