In this codelab, you will install Docker, set up OpenClaw (an open-source, self-hosted AI assistant) in a container, and connect it to a local Ollama model (Gemma) so you can run AI-driven research workflows entirely on your own machine — no cloud API costs required.
Author: Geeta kakrani
GDE IN AI & TPU
Positive : Docker is optional for OpenClaw in general, but this codelab uses the containerized setup so you get an isolated, easy-to-clean-up environment.
.dmg file and drag the Docker icon
into your Applications folder
Open Terminal and run:
docker --version
docker run hello-world
If you see Hello from Docker!, your installation is
working.
Negative : If a popup says "Terminal would like to access data from other apps", click Allow — this is a normal macOS permission prompt for the Docker credential helper.
mkdir -p ~/openclaw-project
cd ~/openclaw-project
git clone https://github.com/openclaw/openclaw.git
cd openclaw
Negative : If git isn't installed yet, macOS will
prompt to install Command Line Developer Tools. Click
Install, wait a few minutes, then re-run the clone
command.
ollama pull gemma3
ollama list
curl http://127.0.0.1:11434
You should see Ollama is running.
Positive : If ollama serve gives an "address already
in use" error, that's fine — it means Ollama is already
running in the background.
From inside the openclaw folder:
export OPENCLAW_IMAGE="ghcr.io/openclaw/openclaw:latest"
./scripts/docker/setup.sh
Walk through the interactive wizard:
Prompt |
Selection |
|
Personal-by-default disclaimer |
Yes |
Setup mode |
QuickStart (recommended) |
Model/auth provider |
Skip for now (we'll configure Ollama separately) |
Default model |
Keep current |
Select channel |
None / Skip |
Search provider |
Skip for now |
Configure skills now? |
No |
Enable hooks? |
Skip for now |
The script will build/pull the image and start the container.
docker compose ps
You should see openclaw-openclaw-gateway-1 with status
Up ... (healthy).
Containers can't reach your Mac via 127.0.0.1 — that
address means the container itself inside Docker. Use
Docker's special hostname instead:
http://host.docker.internal:11434
Run the interactive configure wizard to set this correctly:
docker compose run --rm -it openclaw-cli configure
In the wizard:
http://host.docker.internal:11434
gemma3 or
gemma4:e4b) from the picker
Ollama's local API needs a placeholder API key to be registered as a provider (any value works — it's not a real secret):
echo 'OLLAMA_API_KEY=ollama' >> .env
docker compose up -d --force-recreate openclaw-gateway
Verify the variable made it into the container:
docker compose exec openclaw-gateway env | grep OLLAMA
Get your gateway token:
cat .env | grep TOKEN
Open in your browser, replacing the token placeholder with your actual value:
http://127.0.0.1:18789/?token=YOUR_TOKEN_HERE
Negative : Keep your gateway token private. It grants full control of your OpenClaw instance. Never paste it into chat, screen-share, or share it with anyone — including AI assistants helping you debug.
This usually means a stale token. Fetch a fresh one:
docker compose run --rm openclaw-cli dashboard --no-open
If the token still doesn't work after recreating the container, check whether an old value is cached in your shell session:
echo $OPENCLAW_GATEWAY_TOKEN
unset OPENCLAW_GATEWAY_TOKEN
docker compose up -d --force-recreate openclaw-gateway
In the Control UI chat, confirm the active model and provider:
/models
Switch to your local model if needed:
/model ollama/gemma3
Send a test message:
hi
You should get a response generated entirely by your local Gemma model — no external API calls, no cost.
Find and summarize 3 recent approaches to AI-driven research workflows, with sources.
Observe how the agent breaks the task into steps, gathers information, and structures its output — this is the core capability worth demonstrating live.
Symptom |
Likely cause |
Fix |
|
|
Wizard used container-local address |
Manually enter |
|
|
Missing Ollama API key |
Add |
|
|
Stale or mismatched token |
Regenerate token via |
Mac becomes slow/hangs |
Disk nearly full from Docker images + Ollama models |
Run |
|
|
Docker Desktop didn't auto-start |
Run |
You now have a fully self-hosted AI research assistant running locally — OpenClaw orchestrating a local Gemma model via Ollama, all inside an isolated Docker container with no cloud dependency or per-query cost.
openclaw configure --section web to enable web
search tools
gemma3:1b for speed,
gemma4:e4b for quality)