Skip to main content

Command Palette

Search for a command to run...

Localhost Fun #2: Running Ollama with Docker

Building a free, local AI stack with Docker

Updated
3 min read
Localhost Fun #2: Running Ollama with Docker

I decided to use gpt-oss:20b. Ideally, I would prefer gpt-oss:120b, which would be faster and more capable, or even to plug in an OpenAI API key for significantly better performance. However, this setup is constrained by my local machine. With 32 GB of RAM (Lenovo YOGA 7i), the 20B model is a reasonable and stable choice.

For my use case—interrogating Reddit posts locally and for free—this model is more than sufficient. When I previously tested OpenAI’s gpt-4o-mini, the cost per request ranged between $0.02 and $0.05, which translates to roughly $8–18 per year for my usage. That is not expensive, but the goal here is different: to keep everything local, purely for fun, experimentation, and hands-on experience.

Model reference:
https://ollama.com/library/gpt-oss

Let’s do it!

Run Ollama in Docker

In the terminal, run:

docker run -d \
  --name ollama \
  -p 11434:11434 \
  -v ollama-data:/ollama \
  ollama/ollama:latest

Pull the model into the running container

docker exec -it ollama ollama pull gpt-oss:20b

Verify container state

docker ps -a --filter name=ollama

Start the container

docker start ollama

Verify again

docker ps -a --filter name=ollama

You should see the container running.


Time for a test

Testing via Terminal

Run the model interactively:

$ docker exec -it ollama ollama run gpt-oss:20b

Ask a simple question, for example:

What is Oracle APEX?

While the model is running, my laptop resources spike—CPU and memory usage can easily exceed 90%. This is expected for a local 20B model.

Docker resource usage can be viewed via the Ollama container:
Actions → three dots → View Details → Stats

After some processing time, you should receive a broad and reasonably detailed response:

Testing via HTTP API (Postman)

You can also test Ollama using a REST call. The following endpoints are available:

This makes it easy to integrate Ollama with other tools—or with Oracle APEX.

Testing via Oracle APEX

In a newly created APEX page, I added:

  • Prompt item

  • Response item

  • Button

  • Dynamic Action (Execute JavaScript Code)

Example JavaScript for the Dynamic Action:

console.log("Ollama DA triggered");

var prompt = apex.item("P2_PROMPT").getValue();
console.log("Prompt value:", prompt);

apex.item("P2_RESPONSE").setValue("Thinking...");

fetch("http://host.docker.internal:11434/api/generate", {
  method: "POST",
  headers: {
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    model: "gpt-oss:20b",
    prompt: prompt,
    stream: false
  })
})
.then(response => {
  console.log("HTTP status:", response.status);
  return response.json();
})
.then(data => {
  console.log("Full response from Ollama:", data);
  console.log("Model response text:", data.response);

  apex.item("P2_RESPONSE").setValue(data.response);
})
.catch(error => {
  console.error("Fetch error:", error);
  apex.item("P2_RESPONSE").setValue("Error: " + error);
});

Prompt a simple test, for example:

Hi

The request may take some time to complete, but Docker container logs clearly show activity on the Ollama server.

In my case, even a simple prompt like “hi” took approximately 1 minute and 23 seconds. This is not ideal, but it is acceptable for a local, experimental setup.

and finally:

That means, everything is working as expected, I did working 3 containers, that serving the Oracle 26ai, Oracle APEX (via ORDS) and free AI provider!

At this point, everything is working as expected. I now have three containers running:

  • Oracle 26 AI

  • Oracle APEX (via ORDS)

  • A free, local AI provider (Ollama)

What’s next?

In the next article, I plan to create an n8n workflow that interrogates Reddit posts using this local AI stack.

And finally, yes—I also asked the APEX-related question. Keep in mind that, at the moment, the response is returned without Markdown formatting.

More localhost fun to come.

Localhost Fun

Part 2 of 3

Localhost Fun is a hands-on series about building a full local dev stack with Docker—Oracle DB, APEX, ORDS, local LLMs, n8n automation, and curated Reddit data pipelines—all running on your own machine, with a focus on simplicity and reproducibility.

Up next

Localhost Fun #3: Building a Reddit Automation Pipeline with n8n (Docker)

Low-code workflows, Reddit API, and a local LLM — all running on localhost