Robot Arm Tic-Tac-Toe: Wrapping Up the Project (For Now)

Prussian-blue cyanotype still-life of a tic-tac-toe board and physical ring and cross game pieces

It’s time to put a full stop on my tic-tac-toe robot arm project, at least for now. Over the last few weeks it has grown from “can I get the arm to touch nine squares?” into a working game. An Arduino drives the arm, an AI picks the moves, a camera watches the board, and a set of 3D-printed pieces is designed to be gripped and recognised by colour. Everything now lives in two projects in my GitHub repo, 44-tic-tac-toe-arm and 45-board-camera, along with the board and piece models.

This post wraps the whole thing up in one place. I’ll cover what was built, how it fits together end to end, how it was wired, what I learned and what’s still unfinished. If you want to build your own, every file I mention links straight to the source.

Catching up on the series

If you’re new to the project, here’s the trail of earlier posts on CIAOPS Labs:

The arm itself goes back further. I covered building it in Building a 6DOF Programmable Robot Arm and Robot Arm with Multi Motor Movement.

What was built

At the highest level there are three pieces, and the top-level README lays them out the same way:

  • The arm (project 44). An Arduino UNO R4 WiFi drives six servos directly. It runs the game, hosts its own web pages and talks to Gemini.
  • The camera (project 45). An AI-Thinker ESP32-CAM looks down on the board, works out which cells hold a red X, a yellow O or nothing, and serves that as a nine-character string.
  • The playing field (3d-models/tictactoe). A 180×180 mm printed board and weighted counters designed for the gripper and the camera.

The human always plays yellow O and the robot always plays red X. That isn’t just a style choice. The camera tells the pieces apart by colour, so it matters.

How it was assembled: the component layout

The diagram below is the full layout and connection map, drawn only from what the published firmware and READMEs actually state. Click it for the full-resolution version.

Component layout and connection diagram for the tic-tac-toe robot arm
Component layout and connections, drawn from 44/src/main.cpp, 45/src/main.cpp and the project READMEs. Click for full size.

There are really two kinds of connection here. The first is physical. Six servo signal wires run from the UNO, plus an optional test servo. A USB cable connects the PC to the UNO, and a USB-to-serial adapter is used to program the ESP32-CAM. The second is over the network. The UNO and the camera join the same Wi-Fi, and the UNO asks the camera for the board with a plain HTTP request. There are no signal wires between the UNO and the camera at all.

Here is the servo wiring as it is defined in src/main.cpp (motorPins[] = {0, 1, 2, 3, 4, 5}, auxPin = 11):

MotorUNO R4 pinRole in the firmwareNotes
M0D0Gripper (gripMotor)Home pose = gripper open; closed = open − gripAmount (15°)
M1D1Wrist (wristMotor)Per-square wrist compensation applied at clearance height
M2D2Arm jointName not given in the source
M3D3Lift (liftMotor)Clearance angle 90°; lifts first, lowers last
M4D4Arm jointName not given in the source
M5D5Arm jointName not given in the source
AuxD11Stand-alone test servoNot part of the arm poses; jog it from /calibrate
Servo-to-pin map from the arm firmware.

And the camera side. These are the AI-Thinker module’s own on-board camera connections, set in 45-board-camera/src/main.cpp. You don’t wire them yourself, but they’re worth knowing if you swap boards:

SignalGPIOSignalGPIO
D0 / D15 / 18XCLK (20 MHz)0
D2 / D319 / 21PCLK22
D4 / D536 / 39VSYNC / HREF25 / 23
D6 / D734 / 35SCCB SDA / SCL26 / 27
PWDN32RESETnot used (−1)
AI-Thinker ESP32-CAM pin map used by the camera firmware.

One thing to be upfront about: the repo doesn’t document the servo power supply. It doesn’t say how the servos get their power, whether a shield or external supply sits between the UNO and the servos, or how the camera is mounted above the board. I’ve deliberately left those off the diagram rather than guess. My earlier arm builds used a Keyestudio sensor shield, but this project’s source doesn’t confirm that, so treat power as something you’ll need to size for your own servos.

How it works end to end

A robot turn runs through a fixed sequence, and each step lives in a specific file:

  • Park and look. After the human places a yellow O, the arm moves to its home pose so it’s out of the camera’s view. It waits about 500 ms to settle, then calls GET /board on the ESP32-CAM using board_camera.h. It tries up to three times and needs two identical readings in a row before it trusts the result.
  • Check what changed. camera_board_diff.h compares the camera’s view with the board the arm already knows about. Exactly one new O is accepted as the human’s move. A missing X, no change, or several changes are rejected with a message rather than guessed at.
  • Minimax finds the best moves. tic_tac_toe_rules.h runs a full minimax search and returns every square that is equally best for X, not just one.
  • Gemini picks one. gemini_connection.h sends the board and that list of equal-best squares to Gemini over HTTPS and asks for JSON back, in the form {"square":N}. If Gemini returns a square that isn’t in the minimax set, the firmware rejects it and the arm doesn’t move. The AI adds variety, but it can never make a bad move.
  • The arm moves. It opens the gripper at home, goes to the off-board pickup point and grabs the piece. Then it lifts to clearance, travels, sets the wrist angle for that square, lowers straight down, releases and goes home. If it wins, there’s a victory jig.

The bit I’m happiest with is how the motion is timed. Servo positions are recalculated in a 200 Hz FspTimer interrupt, so a slow Wi-Fi call to Gemini or the camera never freezes the arm halfway through a move. Calibrated poses are stored in EEPROM, so the arm remembers them through a power cycle.

The UNO also serves two web pages. The game page at / is where you play and watch the live output. At /calibrate you can jog each servo, test poses and store the 11 targets: cells 1 to 9, the pickup point and home. The serial commands from the earlier tic_tac_toe.cpp still work too.

The camera

The camera firmware is compact, and you can read the whole thing in one sitting. It captures a 320×240 JPEG, decodes it and averages the colour over the middle half of each of the nine cells, which keeps the grid lines out of the sample. It then sorts each cell into one of three groups:

  • Empty when red minus blue is under 30.
  • Yellow O when green is more than 0.8 times red.
  • Red X otherwise.

It exposes /capture (the photo), /debug (the photo with sample boxes drawn on), /cells (JSON with the colour values) and /board (the nine characters the arm reads, for example X...O....).

Two hardware quirks cost me time and are now written into the code. First, fmt2rgb888 on this board writes bytes in blue-green-red order, not red-green-blue, so byte 2 is red. That was checked on the actual hardware. Second, the camera sees the board rotated 180 degrees, so image index 0 is reported as cell 9. Get either one wrong and the arm will confidently respond to a game nobody is playing.

The printed board and pieces

Repository render of the board with flat counters
Board with flat counters. Repo render: preview.png.

The models README has the details. The board is board.stl / board.3mf at 180×180 mm with 54.67 mm cells. tictactoe_all.3mf packs the board with one X and one O. The one-piece counters (counter_X.stl, counter_O.stl) have a sealed pocket for an M8 washer. You pause the print at Z 5.4 mm, drop the washer in and resume. The extra weight helps the pieces sit flat and release cleanly from the gripper.

Board with tower counters
Tower counters give the gripper something taller to hold. Repo render: preview_tower.png. Files: counter_X_tower.stl, counter_O_tower.stl.
Counters as coloured parts
Print X in red and O in yellow. Repo render: counters_parts.png.

If you’d rather not pause mid-print, the two_part folder has glue-together base and cap versions, including ones sized for a 10 mm washer. The editable source is tictactoe.solidcraft.

Exploded two-part counter
Two-part counter: base, M8 washer and cap. Repo render: preview_exploded.png.

Building it yourself

Both projects are PlatformIO projects with their own platformio.ini (arm, camera). The short version:

  • Copy the templates in 44-tic-tac-toe-arm/include: wifi_secrets_example.h, gemini_config_example.h and camera_config_example.h. Fill in your own Wi-Fi details, Gemini key and URL, and the camera’s address. None of these are committed to the repo.
  • Build and upload the arm with pio run -e uno_r4_wifi -t upload.
  • Copy wifi_secrets_example.h in 45-board-camera/include, then build and upload the camera with pio run -e esp32cam -t upload. The module has no USB port, so use a USB-to-serial adapter and hold IO0 low while resetting.
  • Open /capture and adjust the crop values boardX, boardY, boardW and boardH until the board fills the frame. Then put the camera’s IP address into camera_config.h.
  • Calibrate the 11 poses on /calibrate. This is the step that takes the most patience.

The arm project also has smaller test environments: cell_sequence for a motion-only demo, plus mapping, gemini and tictactoe. They’re handy for testing one layer at a time (cell_sequence.cpp, mapping.cpp, gemini_test.cpp).

What got finished in projects 44 and 45

  • A camera-integrated game firmware, built from main.cpp by default, with a web game page and a calibration page.
  • Motion driven by a timer interrupt, so network calls don’t stall the servos.
  • Minimax as a guard on Gemini’s choices, with a built-in self-test covering wins, draws, invalid moves, openings, forced wins and blocks, and fork defence.
  • Wrist compensation for each square, so pieces arrive straight instead of rotated. README_WRIST_COMPENSATION.md and CALIBRATION_GUIDE.md explain it.
  • Perpendicular descent, so the arm lowers straight down onto a square instead of swinging in at an angle (PERPENDICULAR_DESCENT_FIXED.md).
  • A camera that reads the board, debounced readings and a strict rule for accepting a move.
  • Print-ready board and counters, plus the editable SolidCraft source.
  • A clean public release, with secrets moved into gitignored local headers.

Lessons learned

  • The logic is the easy part. Minimax for tic-tac-toe is a few dozen lines. Getting a hobby servo arm to grab a small piece the same way every time is where most of the hours went.
  • Let the AI choose, but check its answer. Giving Gemini a list of moves minimax has already approved, and rejecting anything outside it, keeps the game interesting without trusting a language model to play perfectly.
  • Keep timing-critical work away from the network. Moving servo updates into a timer interrupt was what made Wi-Fi and the arm work together.
  • Write down your hardware quirks. The BGR byte order and the 180-degree rotation are each one line in the code, and each one would have broken the game without anyone noticing.
  • Small bugs hide in plain sight. For a while the wrist compensation never ran, because the code reset a variable to zero before checking it (CRITICAL_BUG_FOUND_AND_FIXED.md).
  • Never assume the camera is right. Requiring two identical readings and exactly one new piece stops a shadow or a bumped piece from being taken as a move.

What’s left

I said this wraps the project up “for now”, and I meant it. A few things are still open:

  • The camera is still a work in progress. The firmware reads the board, but the colour thresholds and crop are tuned for my lighting and my mount. It needs more testing before I’d call it reliable.
  • Piece holders. The arm currently picks every X from a single pickup point outside the board. The next step is a set of fixed holders off the board, so the arm can collect from several slots in turn without me reloading it.
  • Calibration polish. The wrist compensation values in the code are a calibrated estimate. Each square could be fine-tuned further, and gripper settings are still the main cause of the occasional missed pickup.
  • Power and mounting notes. The repo should eventually document the servo supply and the camera mount, so someone else can reproduce the build without guessing.

What could come next

A few ideas I’d like to try when I come back to it. One is letting the arm clear the board itself at the end of a game. Another is moving from fixed colour thresholds to something that adapts to the lighting. I’d also like to use the camera to check that the arm actually dropped its piece in the right square. And I want to try the same arm, camera and game-logic pattern on a different game. The structure is general: a camera that turns the physical board into a string, a rules engine that defines what’s legal, an AI that chooses within those rules, and an arm that makes it happen.

That’s the real takeaway for me. Each layer is simple on its own. The value comes from joining them up carefully, with checks between each step. If you build your own version, I’d love to see it. Grab the code from my tic-tac-toe folder on GitHub and let me know how you go.

Simulation for improvement

image

If you have been following along with my robot car guided by AI project you’ll know that I got it working with Gemini. I then switched to using Azure AI Foundry. Finally, I changed the code so that car ran most of the local decisions while the AI just made the major navigation decisions.

Each time navigation did improve, but I would have to observe the movements and tell the AI what issues I’d seen and then the Ai would go off and improve the code. I’d then test and update again, round and round in a loop. Each time there was a small incremental change in navigation ability but I still faced edge cases the existing algorithm struggled with.

I could have continued this update, observe, update loop infinitum, making constant incremental improvements. However, when I stepped back and though about how AI systems improve I realised that it was via repetitive learning in a simulated, rather than real environment.

I therefore asked Github Copilot to simulate the algorithm of the robot cars navigation and then test that via simulation. Any improvements learned via the simulation should then be applied back to the robot cars code. I then unleashed Github Copilot to complete this task, without asking for input, until it reached a near prefect navigation result in the simulator.

The result is this code:

https://github.com/directorcia/Azure/blob/master/Iot/LLM/llm-nav-max.ino

which I will say, although far from ‘perfect’ achieved much better results than the incremental ones I was obtaining simply by observational feedback.

The success I’ve had here using the concept of a simulation to test the algorithm and then continue to iterate to improve the code has made me think about what else I could apply this ‘simulation’ process to when other AI work I am performing.

Interesting.

Having the AI make make better decisions

image

After some Ai prompting it was suggested that my robot car navigation would improve if the car did more itself with local routines and only used the AI when it could not decide so I plugged away and ended up with this code:

https://github.com/directorcia/Azure/blob/master/Iot/LLM/llm-nav-max.ino

you will see:

An ESP32 robot car drives forward until its ultrasonic sensor (mounted on a pan servo) detects an obstacle.  On each hazard event a two-tier decision pipeline fires:

1. LOCAL PLANNER  – scores three candidate maneuvers (strafe, 90° turn, and  backup+turn) using live L/F/R distance readings, front-clearance trend, and oscillation history.  If the result is “obvious” (high confidence, low risk, no repeated-trap condition) it is executed immediately without any network round-trip.


2. FOUNDRY ARBITER – when the local answer is ambiguous, or a repeated-trap is detected, a structured prompt is posted to an Azure AI Foundry Responses API endpoint.  The LLM names one candidate plan and returns a confidence score. The response is validated and sanitized; any failure falls back to the local plan.


After every maneuver the robot re-scans, records the front-clearance delta, and feeds plan quality (improved / worsened) back into the next decision cycle.

After a quick test, navigation does seem more intelligent, although it seems to make decisions a long way away and tends to get lost in wide open spaces with object far away. However, I think that if I nvested more time I could improve all that.

I have an additional idea on how I might improve the navigation in an upcoming article, but for now I think I’m pretty much done with the concept of navigation.

Connecting the robot car to Azure AI Foundry

image

If you have been following along you will know that I’ve connected a robot car to both a local LLM and cloud based Gemini. The last iteration is here:

https://blog.ciaopslabs.com/2026/07/18/controlling-a-robot-car-with-ai/

I decided that I should connect the car to Azure AI Foundry because there are so many more models available as well as everything else that comes with Azure.

Screenshot 2026-07-19 091107

So I set up a simple Foundry project

Step 1: Create an Azure AI Foundry Project

  1. Browse to Azure AI Foundry:

    Azure AI Foundry

  2. Sign in with your Azure account.
  3. Select:
    • Create Project
    • Project Name:
      RobotNavigation
      
  4. Create or select:
    • Azure Subscription
    • Resource Group
    • Azure AI Services Resource
  5. Wait for deployment to complete.

 


Step 2: Deploy a Model

Within your Foundry project:

  1. Open:
    Model Catalog
    
  2. Deploy:
    • GPT-5-mini
    • GPT-5.1-mini
    • GPT-4.1-mini

For a robot car:

GPT-5-mini

is usually sufficient and inexpensive.


Step 3: Obtain Connection Details

From Foundry copy:

Endpoint URL

API Key

Model Name

 

C++

#define FOUNDRY_RESPONSES_URL \

“https://robot-navigation-resource.services.ai.azure.com/openai/v1/responses”

#define FOUNDRY_MODEL “gpt-5-mini”

 

The recommendation was the use the gpt-5-mini model, so I plugged it into the existing code, made a few improvements and ended up with this:

https://github.com/directorcia/Azure/blob/master/Iot/LLM/llm-foundry.ino

My observation is that the navigate is generally better but the delays are longer when it has to ‘thinlk’ (aka go to the LLM). This has to do with the size of model, basically gpt-5-mini vs gemini3-flash.

So, the lesson here is I need the smallest possible model for the job. For now I’ll stick with gpt-5-mini.

So more research indicates that I shoudl probably offload more processes to the local device and only the LLM at a much higher level. A better plan seems to bei instead of asking the LLM to invent a manoeuvre plan, ask it to choose from local candidate plans you already created.

So let me go and try that now.

 

 

Controlling a robot car with AI

image

After having AI show my fortune, the next project was having AI navigate my robot car.

To keep things simple I constrained movement to a 5 x 5 grid ( X = 0 – 4 and Y = 0 – 4) and the car could only move N, S, E or W one cell at a time. To get the algorithm right and test this with Ai before actually applying it to the car I simulated the result on the OLED screen I had previously configured.

With that all working I upgraded the code to run with the robot car and you’ll find it here:

https://github.com/directorcia/Azure/blob/master/Iot/LLM/llm-cellmove.ino

The main issue I found was more mechanical with the robot car wheels dragging and not being very precise, so the car woudl easily wander off in different directions. This has more to do with teh quality of the motors and wheels as well as the friction encountered when the wheels start moving. However, aside from that the test worked successfully and the car cycled up the grid and then back down.

Next, I wanted the AI to actually assist with the navigation of the car. I went through plenty of iterations with this. The most important change is that I moved from using a local AI to using Gemini via API calls. The main reason for this was simply speed. As the prompts became larger the local AI model struggled to return the results to the car in enough time to implement effective navigation. I had also wanted to integrate large cloud based LLM so here was the opportunity, so I hooked up Gemini.

The robot car also has an ultrasonic senor connected to a motor at the front so I could sweep it left and right as well for better object detection. However, initially I kept it simple and all on teh car by just using the ultrasonic sensor to detect hazards and try to makeover around them. The code for that is here:

https://github.com/directorcia/Azure/blob/master/Iot/LLM/llm-sweep.ino

I then upgraded the code to integrate the LLM into the navigation process by making decisions on which direction to turn. That code is here:

https://github.com/directorcia/Azure/blob/master/Iot/LLM/llm-sweep.ino

One issues I ran into, that wasted a lot of my time and was totally my own fault, was when I started having issues with the wheel moving the car forward. I blamed the code but in fact, again it was a hardware issue, being the battery charge had become too low to actually drive the wheels acceptably. It is interesting at how quickly that car now actually drains power when fully running.

With the power issues resolved I upgraded the code a number of times to allow the LLM a much higher level of navigation control. You’ll find the final result here:

https://github.com/directorcia/Azure/blob/master/Iot/LLM/llm-assist-nav.ino

The end result of all these experiments is that I have learned that in the full configuration the car now burns a lot of power as it moves, turns the sensor, communicates over wifi and more. all the changes I made to the code would make the car slightly less likely to crash into objects on the floor but a lot more though needs to go into ‘crash free’ navigation. The obvious improvement is to add more sensors to provide the LLM with more information to make better decisions. I also found that the wheel on the car are not precise enough and don’t really provide the best grip. This means they tend to be slow to engage and lag cause the car to veer.

I think all of these can be solved iteratively over time and I am confident that I can get to a situation that allows the robot car to move pretty much crash free around the floor just like a robot vacuum can already. However, the time required is probably not something that I’m willing to invest in just now to get a little incrementally better. I’m happy that my ‘proof of concept’ when it comes to navigation with LLMs works. I think it is time to move onto the next project.

Having the device show my fortune

After getting the ESP32 talking to the local LLM the next stage was to do something more than just flashing an LED. I decided that I’d use the LLM to produce a ‘fortune’ for me and then display that on an OLED screen I’d connect to the ESP32.

The OLED screen in question was this White I2C OLED display (SSD1306).

White I2C OLED display (SSD1306)

To use this OLED you need the Adafruit_SSD1306 library.

Here is the prompt being sent to the local LLM:

You are a mystical fortune teller. Give one short fortune. Maximum 12 words.  No introduction. No quotes.

The result from the LLM is then displayed on the OLED screen which is connected to the ESP32-C3-DevKitM-1 via GPIO6 and GPIO7 acting as SDA and SCL communication ports. I also left the external LED on GPIO4, from the last project, as well to aid troubleshooting.

The code is here:

https://github.com/directorcia/Azure/blob/master/Iot/LLM/llm-fortune.ino

and the results look like:

Screenshot 2026-07-10 084030

Video URL = ESP32 displaying results from local LLM

Getting device talking to LLM

With the LLM now up and working on a separate device on my LAN, the next step is to test it remotely to ensure that it works. For this I used the following simple PowerShell on a remote machine



which you will find here:

https://github.com/directorcia/Azure/blob/master/Iot/LLM/echo-ping.ps1

Next, I ran the following PowerShell script:

https://github.com/directorcia/Azure/blob/master/Iot/LLM/echo-test.ps1

which simply runs a standard prompt of;

“Reply with exactly: Hello from Ollama”

and then ensure that I get that reply back from the remote LLM server. This means I have communications to the actual server as well as the LLM.

With all the remote communications confirmed, the next step was to get a device talking to the LLM. For this I had a ESP32-C3-DevKitM-1 hanging around.



The main benefit of this device is that it has inbuilt Wifi. I connected up a LED and resistor to GPIO4 like so:





I then used this code in the device:

https://github.com/directorcia/Azure/blob/master/Iot/LLM/llm-flash.ino

to prompt the LLM for a number of flashes from 1 – 4, which the device would then complete that on the LED. I could also monitor the progress using the terminal, which would look like:

Connecting to Wi-Fi…..
Wi-Fi connected. IP: 192.168.1.42
Requested flash count: 3
Sending request to Ollama (attempt 1)…
HTTP status: 200
Ollama reply: {“flash”:3}

Initially I found that the LLM was returning the same number of flashes, so I needed to adjust the prompting to get some variation. The good news is that I got it all working and the resultant code is above.

So now I have successfully gotten a device talking to a local LLM. I’ll be expanding on this in upcoming articles but very happy that have this basic configuration all working now.

The local AI system so far

image

You can describe it like this:

  • The user connects via browser to the host machine

  • The request hits Open WebUI (running in Docker)
  • Open WebUI calls the Ollama API on port 11434
  • Ollama processes the request using local models
  • The response flows back to the browser


Simple mental model

Browser → WebUI → Ollama → Model → Response

Set up Summary

Getting Ollama running on Windows

– How to install Linux on Windows with WSL

Docker and Open WebUI deployment on Windows

Why Docker was needed

Why Open WebUI is required

Why Open WebUI is required for local AI

I am creating a local AI machine that runs Ollama. Steps completed so far:

Getting Ollama running on Windows

Docker and Open WebUI deployment on Windows

Why Docker was needed

Open WebIU is a critical design point in what you built, and understanding it properly will change how you think about deploying AI systems.

I’ll explain it clearly in the context of your setup — not generic theory.


The short answer

You needed to run Open WebUI on the same machine as Ollama because:

The machine running Ollama is the one doing the actual AI processing, and Open WebUI must run close to it to reliably act as the interface.

Everything else should just connect to that machine via a browser, not try to run AI locally.


What is actually happening in your setup

You now have three roles:

1. The host machine (Ollama PC)

This is your AI server

It runs:

  • Ollama → the AI engine (models, GPU/CPU work)

  • Open WebUI → the web interface

  • Docker → runtime for WebUI


2. The guest machines

These are clients only

They:

  • do not run models

  • do not run WebUI

  • simply connect via browser


3. The browser

The browser is the user interface, not the AI itself


The critical dependency chain

Your system works like this:

Browser → WebUI → Ollama → Model → Response


Why WebUI MUST be on the Ollama machine

1. WebUI is a frontend, not an AI engine

Open WebUI does not run models.

It:

  • sends prompts

  • receives responses

  • renders a chat interface

If you run WebUI on another machine:

  • it has no local models

  • it must connect over the network to Ollama

  • you introduce unnecessary complexity


2. Local communication is simple and reliable

When WebUI runs on the same machine:

  • Connection to Ollama is:
    http://localhost:11434
    

    (internal, fast, reliable)

If WebUI runs on another machine:

  • You must use:
    http://<host-ip>:11434
    
  • Requires:

    • firewall rules

    • correct binding

    • network stability

    • security considerations


Why this matters

You already saw issues like:

  • connection failures

  • unhealthy containers

  • network access problems

Running WebUI locally eliminates most of those.


3. Performance (this is often overlooked)

AI workloads are:

  • CPU/GPU intensive

  • heavy in memory usage

  • sensitive to latency

If WebUI is remote:

  • every prompt travels across the network

  • every token response comes back across the network

While not huge, it adds:

  • latency

  • potential instability


Local WebUI gives:
  • near-zero latency between UI and model

  • predictable performance

  • fewer moving parts


4. You centralise compute instead of duplicating it

Your goal was:

“Run AI from another machine”

That does NOT mean:

“Run AI on every machine”


Correct design:
One machine → does compute
Many machines → access it


If you ran WebUI remotely

You would either:

  • duplicate the WebUI install everywhere

  • or still point it back to the same Ollama server

Which gives you:

  • more complexity

  • no real benefit


5. Security and control

When everything runs on the Ollama machine:

  • you control:

    • firewall

    • ports

    • access
  • you know exactly where the AI is running

If WebUI is spread across multiple machines:

  • more endpoints

  • more risk

  • harder to manage access


6. Docker networking works naturally this way

This was a key issue you hit:

You had to use:

host.docker.internal

This only works cleanly because:

  • WebUI container = local to host

  • Ollama = local to host


If WebUI was on another machine:

  • Docker networking helps you less

  • you rely purely on LAN configuration

  • more points of failure


7. This is how real systems are designed

What you built mirrors real-world architecture:

Client → Web App → API → Compute

In your case:

Browser → WebUI → Ollama → Model


This is the same pattern used by:

  • ChatGPT (frontend separate from engine)

  • Azure AI services

  • enterprise AI platforms


8. Scaling (this is the big future reason)

Running WebUI on the Ollama host allows you to:

  • add components easily:

    • vector databases

    • RAG pipelines

    • APIs
  • keep all services close together


If WebUI is remote:

  • scaling becomes messy

  • service orchestration becomes harder


What would happen if you didn’t do this

Let’s be very direct.

If you ran WebUI on a different machine:

You would need to:

  • configure Ollama network access properly

  • open firewall ports correctly

  • deal with API connectivity issues

  • troubleshoot latency and failures

  • manage multiple installation environments

And still end up with:

  • no performance gain

  • more complexity

  • harder troubleshooting


The real reason (simplified)

You ran WebUI on the host machine because:

The AI models must run locally on one machine, and WebUI must sit as close as possible to that engine to provide a reliable interface.


The correct mental model

Do not think:

“I am running WebUI on a machine”

Think:

“I am exposing an AI service from one machine to the rest of my network”


Final takeaway

Running WebUI on the Ollama machine:

  • keeps the system simple

  • reduces network complexity

  • improves reliability

  • centralises compute

  • aligns with real architecture patterns


One practical recommendation

Once you’re comfortable, the next step is:

  • add authentication back into WebUI

  • restrict access to trusted devices

This turns your setup from a lab into a proper internal AI service.

Ollama + Open WebUI deployment

I am creating a local AI machine that runs Ollama. Steps completed so far:

Getting Ollama running on Windows

Docker and Open WebUI deployment on Windows

In this case, Docker wasn’t just “nice to have”, it solved several very specific problems in your setup.


WHY DOCKER WAS NEEDED IN THIS SPECIFIC SETUP

1. Open WebUI is not designed as a simple Windows app

Open WebUI is built as a:

  • Python web application

  • With multiple backend dependencies

  • Designed primarily for Linux-style environments

Without Docker, you would have needed to:

  • Install Python (correct version)

  • Install pip dependencies

  • Handle compatibility issues

  • Configure environment variables manually

  • Run a web server process

This is fragile and error-prone on Windows.


What Docker did here

When you ran:

docker run ghcr.io/open-webui/open-webui:main

Docker:

  • Pulled a prebuilt environment
  • Contained everything (Python, libraries, configs)

  • Started the service automatically

So instead of building the environment, you consumed a known-good one


2. You needed a clean separation between components

Your architecture now looks like:

Ollama (host)
Open WebUI (container)
Browser (client)

Without Docker:

  • WebUI and Ollama would run on the same OS

  • Dependencies could conflict

  • Debugging becomes harder


What Docker did here

Docker created an isolated runtime for WebUI:

  • WebUI does not interfere with Windows

  • WebUI does not interfere with Ollama

  • You can remove/rebuild it safely

This is especially important as you expand (RAG, APIs, agents)


3. You needed predictable networking

One of the key issues you hit was:

  • WebUI couldn’t talk to Ollama

  • Needed host.docker.internal


Why Docker matters here

Docker introduces a controlled networking model

Instead of:

  • Random ports

  • OS-level binding issues

You get:

  • Defined port mapping: 3000 → 8080
  • Clear host access: host.docker.internal

This makes multi-service communication predictable


4. You needed rapid rebuild and recovery

You hit several issues:

  • Wrong container name

  • Auth issues

  • Unhealthy container

  • Image typo

Without Docker:

You would have had to:

  • uninstall software

  • clean configuration

  • reinstall dependencies


What Docker enabled

You fixed everything with:

docker rm -f open-webui

docker run …

Full rebuild in seconds, with zero cleanup

This is one of Docker’s biggest practical advantages.


5. You needed a deployable, repeatable system

Right now, what you built can be:

  • Recreated on another machine

  • Documented

  • Given to another tech

  • Deployed to a client


Without Docker

You would need:

  • A long install guide

  • Environment matching

  • Manual steps that can fail


With Docker

You only need:

docker run …

That’s a deployment standard, not just a setup


6. You needed multi-device access

Your requirement was:

“Access Ollama from other machines”

Docker enabled:

  • Running WebUI as a central web service
  • Exposing it safely via a single port

  • Allowing browser-based access


Without Docker

You would:

  • struggle to host a local web service reliably

  • deal with Windows service management

  • manually run servers


7. You needed extensibility (this is the big one)

Right now you have:

  • Ollama

  • Open WebUI

But next steps are:

  • RAG systems

  • Vector databases

  • APIs

  • Agent frameworks


Docker becomes critical here

Because it allows you to:

  • add services without breaking others

  • isolate each component

  • scale architecture cleanly

Example future stack:

WebUI → Ollama → Vector DB → API → Tools

This only scales cleanly with containerisation


8. Docker solved Windows-specific limitations

This part is often missed.

You are running on Windows.

Many modern AI tools assume:

  • Linux environment

  • Unix-style dependencies

  • specific runtime behaviour


Docker (via WSL2) solved this

Docker gave you:

  • a Linux-compatible runtime

  • consistent behaviour

  • no need to rewrite apps for Windows

Without Docker + WSL:

  • many tools simply would not run properly


THE REAL REASON DOCKER WAS REQUIRED HERE

In your exact setup, Docker was needed because:

You were running a modern, Linux-native, dependency-heavy application (Open WebUI) on a Windows machine and needed it to connect reliably to another local service (Ollama) while being accessible across the network.

Docker solved:

  • environment compatibility

  • dependency management

  • service isolation

  • networking consistency

  • deployment repeatability


WHAT WOULD HAVE HAPPENED WITHOUT DOCKER

Let’s be blunt:

You likely would have spent hours:

  • installing dependencies

  • fixing Python errors

  • resolving compatibility issues

  • debugging network bindings

And still ended up with:

  • a fragile setup

  • difficult rebuild process

  • non-repeatable deployment


PRACTICAL SUMMARY

Docker was not used here because it is “modern”.

It was used because it enabled:

  1. Running Open WebUI without manual setup

  2. Isolating it from your system

  3. Connecting it reliably to Ollama

  4. Recovering quickly when things break

  5. Making the system repeatable and deployable

  6. Supporting future expansion


FINAL TAKEAWAY

In this scenario:

Docker transformed a complex, fragile, multi-component system into a predictable, repeatable, and easily recoverable deployment.

That is exactly why it exists.