Build Android 15 (AOSP) with Docker on Ubuntu 24.04

On this page7 sections

Why Docker Instead of Podman?

While Podman supports rootless builds, Docker is the better choice for most users, especially in CI/CD pipelines:

  • Native integration with Jenkins, GitHub Actions, GitLab CI
  • Backed by a mature ecosystem and community

If you’re considering Podman, also read:
Android 15 AOSP Build with Podman on Ubuntu 24.04

Prefer a ready-to-run container? Pull my image from Docker Hub:
https://hub.docker.com/repository/docker/cdlee/aosp-builder/general

Prerequisite: Install Docker

Follow this step-by-step guide:
Install Docker on Ubuntu 24.04

Once Docker is working and your user is in the docker group, continue below.

1. Set Up Build Context

mkdir ~/aosp-builder && cd ~/aosp-builder

Dockerfile

FROM ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive
ENV LANG=C.UTF-8
ENV USE_CCACHE=1
ENV CCACHE_DIR=/ccache
ENV CCACHE_EXEC=/usr/local/bin/ccache

RUN apt-get update && apt-get install -y --no-install-recommends \
    git-core \
    gnupg \
    flex \
    bison \
    build-essential \
    zip \
    curl \
    zlib1g-dev \
    libc6-dev-i386 \
    x11proto-core-dev \
    libx11-dev \
    lib32z1-dev \
    libgl1-mesa-dev \
    libxml2-utils \
    xsltproc \
    unzip \
    fontconfig \
    rsync \
    openssl \
    && apt-get clean

COPY ccache /usr/local/bin/ccache

WORKDIR /workspace

Place your custom ccache binary as ./ccache (make sure it’s executable).

Build ccache 4.11.3 from Source on Ubuntu 24.04

2. Build the Docker Image

docker build -t aosp-builder .

3. Run the Build Environment

Assuming AOSP 15 source is already synced in ~/aosp-15:

docker run -it --rm --user $(id -u):$(id -g) \
  -v .:/workspace -v /home/administrator/.cache/ccache:/ccache \
  aosp-builder bash

This will give you a shell inside the container, running with your host user permissions.

Note About Shell Prompt and Group Warnings

When you use --user with a UID/GID not defined in /etc/passwd or /etc/group inside the container (e.g., 1001:1001), you might see:

groups: cannot find name for group ID 1001
I have no name!@<container-id>:/workspace$

This is expected and harmless. It just means that the user doesn’t have a name entry inside the container. You can still build and run everything normally.

4. Build AOSP

Once inside the container:

source build/envsetup.sh
lunch aosp_arm64-trunk_staging-userdebug
m

The build runs cleanly under your host UID/GID, so no permission problems when accessing files from your host.

You now have a minimal, production-grade AOSP 15 build setup using Docker, great for both local and CI/CD use.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top