Using Apple Containers
This setup is more secure than a non privileged macOS account. You need the latest Apple Containers release: https://github.com/apple/container.
Follow the steps in order. Each step builds on the last.
1. Create the Dockerfile
Create a file named Dockerfile to provision an Ubuntu image with systemd and Ollama. The systemctl mask commands follow Apple’s documented recommendations for their container environment so the VM boots fast 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
2. Start the container system and build the image
1 container system start
2 container build -t local/ollama-machine:latest .
The first build can take a few minutes.
3. Create the machine
1 container machine create local/ollama-machine:latest --name little-coder-env
2 container machine set -n little-coder-env cpus=8 memory=16G
You only create the machine once. To reclaim all disk space later, stop and remove it (see step 6).
4. Open a shell and start Ollama inside the VM
1 container machine run -n little-coder-env
Inside the container shell:
1 sudo systemctl enable ollama
2 sudo systemctl start ollama
3 sudo systemctl status ollama
4 ollama pull gemma4:12b-it-qat
You only need to download the model once to the container.
5. Run little-coder and work
Inside the same container shell:
1 little-coder --model ollama/gemma4:12b-it-qat
When done, leave the session and stop the container:
1 exit
2 container machine stop little-coder-env
6. Useful commands
1 # Drop into a shell again (fresh boot cycle)
2 container machine run -n little-coder-env
3
4 # Gracefully halt the kernel
5 container machine stop little-coder-env
6
7 # Delete the container
8 container machine rm little-coder-env
9
10 # Reclaim all disk space
11 container machine stop little-coder-env
12 container machine rm little-coder-env
13 container image rm local/ollama-machine:latest