Optional Material: Using Apple Containers

Here we look at a setup that is more secure than simply running in a non privileged macSO account as we did in the previous chapter. You need to download and install the latest release for Apple Containers: https://github.com/apple/container.

Create the Dockerfile

Create a file named Dockerfile to provision an Ubuntu image with systemd and Ollama. The specific systemctl mask commands follow Apple’s documented recommendations for their container environment to ensure the VM boots quickly without hanging on unavailable hardware interfaces.

 1 FROM ubuntu:24.04
 2 ENV container container
 3 
 4 # 1. Install base OS management dependencies
 5 RUN apt-get update && \
 6     apt-get install -y \
 7     dbus systemd openssh-server net-tools iproute2 iputils-ping \
 8     curl wget vim-tiny man sudo pciutils zstd build-essential gnupg
 9 
10 # 2. Inject NodeSource PPA and install Node.js 22 + npm
11 RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
12     apt-get install -y nodejs
13 
14 # 3. Download and install Ollama Linux binary
15 RUN curl -fsSL https://ollama.com/install.sh | sh
16 
17 # 4. Install the little-coder framework globally
18 RUN npm install -g little-coder
19 
20 # Clean up apt caches to minimize image size
21 RUN apt-get clean && rm -rf /var/lib/apt/lists/*
22 
23 # 5. Systemd configuration for Apple Host Integration
24 RUN >/etc/machine-id && >/var/lib/dbus/machine-id
25 RUN systemctl set-default multi-user.target
26 RUN systemctl mask \
27     dev-hugepages.mount \
28     sys-fs-fuse-connections.mount \
29     systemd-update-utmp.service \
30     systemd-tmpfiles-setup.service \
31     console-getty.service
32 RUN systemctl disable networkd-dispatcher.service
33 RUN sed -i -e 's/^AcceptEnv LANG LC_\*$/#AcceptEnv LANG LC_*/' /etc/ssh/sshd_config

Use the container CLI to build the OCI image locally

1 container build -t local/ollama-machine:latest .
1 container machine create local/ollama-machine:latest --name little-coder-env
2 container machine set -n little-coder-env cpus=8 memory=16G
1 container machine run -n little-coder-env -- little-coder --model ollama/gemma4:12b-it-qat
 1 $ container machine stop little-coder-env
 2 $ container machine run -n little-coder-env
 3 
 4 ### Deleting the container
 5 container machine rm little-coder-env
 6 
 7 # 1. Gracefully halt the underlying Linux kernel
 8 container machine stop little-coder-env
 9 
10 # 2. Drop into an interactive shell to trigger a fresh boot cycle
11 container machine run -n little-coder-env
12 
13 # 3. Enable and start the systemd service layer for Ollama inside the VM
14 sudo systemctl enable ollama
15 sudo systemctl start ollama
16 
17 # 4. Check to verify the daemon is active and listening
18 sudo systemctl status ollama
19 
20 # 5. Pull the newly released Gemma 4 compression-optimized model directly
21 ollama pull gemma4:12b-it-qat
22 
23 # Tada! Run little-coder:
24 little-coder --model ollama/gemma4:12b-it-qat
25 
26 # after working in your little-coder session, use exit to leave the container and stop the container:
27 
28 exit
29 container machine stop little-coder-env

You only need to download the model once to the container.

Reclaiming Disk Space

If you want to reclaim all disk space:

1 container machine stop little-coder-env
2 container machine rm little-coder-env
3 container image rm local/ollama-machine:latest