Using a Dockerized PI with Ollama to code Laravel project running in a Docker container. PI is a minimal harness, but it has no guardrails, so it can alter your system with the same rights as the user running it. So it can install packages.
Dockerized PI image
The Dockerfile:
FROM node:24-bookworm-slim
# Package iputils-ping is not needed but easy for debugging purposes
RUN apt-get update \
&& apt-get install -y --no-install-recommends bash ca-certificates git ripgrep iputils-ping \
&& rm -rf /var/lib/apt/lists/*
RUN npm install -g --ignore-scripts @earendil-works/pi-coding-agent
WORKDIR /workspace
ENTRYPOINT ["pi"]
Create the image with:
docker build -t pi-sandbox -f Dockerfile .
Not strictly needed, but I want to use a separate config directory for the Dockerized PI. So create the directory:
mkdir ~/.pi/agent_docker
Add the models.json file with the following content. Note that we here use http://host.docker.internal instead of http://localhost because Ollama is run on the localhost of the host, so Docker needs to use host.docker.internal to access it. Also replace the model below with your model.
{
"providers": {
"ollama": {
"baseUrl": "http://host.docker.internal:11434/v1",
"api": "openai-completions",
"apiKey": "ollama",
"models": [
{
"id": "north-mini-code-1.0:q4_K_M"
}
]
}
}
}
Also change the settings.json file:
{
"lastChangelogVersion": "0.87.1",
"theme": "light",
"defaultProvider": "ollama",
"defaultModel": "north-mini-code-1.0:q4_K_M"
}
Now you can start the container, but make sure to do this in the project directory you want to let PI assist you. In the below example $PWD points to your current working directory, which needs to be the project directory you want to code. We also mount the settings directory, so PI can access it:
docker run --rm -it \
-v "$PWD:/workspace" \
-v ~/.pi/agent_docker:/root/.pi/agent \
pi-sandbox