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
First start the container system:
1 container system start
Now build a container (might take a minute or two the first time you do a build:
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 run -n little-coder-env
Now work inside the container. When you are done exit the container shell and stop the container:
1 container machine stop little-coder-env
Here is a listing of useful commands:
1 ### Deleting the container
2 container machine rm little-coder-env
3
4 # 1. Gracefully halt the underlying Linux kernel
5 container machine stop little-coder-env
6
7 # 2. Drop into an interactive shell to trigger a fresh boot cycle
8 container machine run -n little-coder-env
9
10 # 3. Enable and start the systemd service layer for Ollama inside the VM
11 sudo systemctl enable ollama
12 sudo systemctl start ollama
13
14 # 4. Check to verify the daemon is active and listening
15 sudo systemctl status ollama
16
17 # 5. Pull the newly released Gemma 4 compression-optimized model directly
18 ollama pull gemma4:12b-it-qat
19
20 # Tada! Run little-coder:
21 little-coder --model ollama/gemma4:12b-it-qat
22
23 # after working in your little-coder session, use exit to leave the container and stop the container:
24
25 exit
26 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