Open WebUI with Ollama in Docker: build a local AI chat that keeps its history
Run a browser chat with Docker Compose and a local Ollama model. Download the example, try a real ticket, and check that your conversation survives a container replacement.

Open WebUI gives you a browser interface for talking to a language model. Pair it with Ollama and you can run the model on your computer, keep a list of conversations and pick up a thread the next day. It makes sense if you already use a model in the terminal, want to work with local notes, or need to find out exactly where a message goes before trying a new tool at work.
We will build a small chat, ask it to extract a ticket number, and check the same conversation after replacing the containers. You need Docker with Compose, room for two application images and a model, and an internet connection for the initial downloads. The exercise uses local inference throughout. Download the Compose project, key generator and sample ticket.
Follow one message through the system
Suppose you paste an email into the chat. The browser sends the text to Open WebUI. Open WebUI asks Ollama to run the selected model, then sends the answer back to your tab. The model weights are loaded by Ollama. If a long conversation takes a minute to answer, changing browsers is unlikely to make much difference. Choosing a smaller model, shortening the conversation or giving Ollama more resources can change the result.
The distinction also tells you where to look for missing data. We give Ollama a Docker volume called models. The interface gets a second volume called chats for its application data, including users, settings and conversations. If the model picker looks normal but your history is empty, check the account and the interface volume. If your conversation is there but there is nothing to select, check the connection to Ollama and its model volume.
You could run all of this without a browser. The Ollama installation and first-prompt guide covers the command-line route. Keeping the two services separate here lets you try a different version of the interface without downloading the model again. How Open WebUI connects to Ollama.
Download Open WebUI and prepare Docker
On Windows or macOS, Docker Desktop is a common starting point. On Linux, Docker Engine with the Compose plugin also works. Open a terminal and run docker version, followed by docker compose version. Look for a server version as well as a client version. If the client reports that it cannot connect to the Docker engine, start Docker first. Reinstalling the chat application would do nothing about that particular error.
Extract the download into a permanent directory such as local-chat and open your terminal there. The project pins Open WebUI v0.13.5-slim and Ollama 0.40.19. The slim image suits this text-only experiment. Some document, embedding and audio features need extra components with slim. Getting a chat reply does not demonstrate that your installation can read a scanned PDF or search a folder of documents. Installation options and image variants · Open WebUI v0.13.5 release.
Create a signing key once. With Python 3 on macOS or Linux, run python3 make_env.py. With the Python launcher on Windows, run py -3 make_env.py. The helper creates a file called .env next to compose.yaml and puts a random WEBUI_SECRET_KEY inside. Repeating the command keeps the existing key. This is a local application secret for signing sessions. You do not need a vendor account to obtain it. Keep your copy out of any archive you send to someone else.
There are two addresses to remember. Your browser uses http://127.0.0.1:3000. Open WebUI uses http://ollama:11434 to reach the service named ollama inside the Compose project. The Docker file exposes the browser interface only on the host's loopback address. It doesn't publish the Ollama port. That is a useful default for a single-person test: a colleague across the room cannot open your chat just by knowing your computer's address. Official Ollama Docker guide.
Start the interface and load your first model
Run these commands from the directory containing the Compose file:
docker compose config -q
docker compose up -d
docker compose ps
The first command validates the configuration without printing your key. The second downloads missing images and starts both services. The third tells you what is running. On the first visit, a container can be running while the application is still creating its database. Check docker compose logs --tail 50 webui if the page takes a while to appear. If another program uses port 3000, add WEBUI_PORT=3001 on its own line in the existing .env, run docker compose up -d again, and open port 3001. Keep the port inside the web container at 8080.
Open the page and use Get started to create the first local account. The first user on a fresh instance becomes its administrator. The credentials belong to this installation of Open WebUI. Leave the interface on loopback while setting it up. Next, download a deliberately small model for a quick test:
docker compose exec ollama ollama pull qwen2.5:0.5b
docker compose exec ollama ollama list
The name appears twice in the first command because Compose and the application use the same word. The first ollama selects the running service. The second starts the Ollama program inside it. In our test the model list showed ID a8b0c5157701 and 397 MB on disk. The public model card rounds the download to 398 MB. Neither number is the disk requirement for the entire project. Allow space for both application images, the conversation database and additional models you choose later. Qwen2.5 0.5B model card.
A practical test with a support ticket
Choose qwen2.5:0.5b in the model selector above the composer. Start a regular new chat, open ticket.txt and paste its single line. Both language editions of this guide use the same prompt so the output is easy to compare.
Ticket KM-417. The cabinet arrived without a handle. Reply with the ticket code only.
The expected answer is KM-417. The task is small on purpose. It tests that the browser can see a model, that the interface can send it a message, and that text can come back. A correct answer to one ticket would be weak evidence for choosing a model to process customer complaints. That decision calls for a set of messages with missing information, conflicting identifiers and realistic mistakes.
What happened on the test machine. We capped each container at one CPU and 2 GiB of RAM. A plain API call returned KM-417. In the browser, the small model left the assistant message empty with the default tool-calling mode. To make the test repeatable we created a profile called km-ticket using the same weights. The included Modelfile specifies one CPU thread, a 2,048-token context, temperature zero and a maximum of 64 output tokens. Creating the profile reuses the weights already on disk.
docker compose cp Modelfile ollama:/tmp/km-demo.Modelfile
docker compose exec ollama ollama create km-ticket -f /tmp/km-demo.Modelfile
Select km-ticket:latest in a new chat. Open Model controls → Advanced Params → Function Calling, change Default to Legacy, and send the ticket again. We saw exactly KM-417 in the assistant's reply. We then recreated both containers and signed in from a fresh browser session. The same conversation opened with the question and answer intact, and both model entries were still present. Legacy is a compatibility setting for this text exercise. Native is the supported mode for modern tool use. Evaluate an agent separately with a model suited to that job. Tool-calling modes · Ollama Modelfile reference.
For a useful follow-up, try a second email without a ticket number. Tell the model to return the word “missing” if it cannot find one. If it repeats the earlier code, try that email again in an empty conversation. This separates the effect of chat history from a habit of inventing details. Verify any extracted identifier against the original email or your system of record before creating a customer-facing task. For the next step of that process, see the n8n intake workflow.
Stop the application without losing a conversation
Save the name or local URL of your test chat. Run docker compose down, then docker compose up -d. Wait for the interface, sign in with the same account and open the conversation from history. Finally, run docker compose exec ollama ollama list to check the second half of the setup. The presence of a model in that list alone would tell you nothing about the conversation database.
The extra flag in docker compose down -v changes the operation substantially. It removes the project's volumes and their contents. An ordinary shutdown only needs down. For a backup, keep both volumes and the environment file, and stop writes while copying the local database. A practical recovery test is to restore the copy to a separate project and open a conversation whose contents you already know.
Changing a directory name can also produce a surprisingly convincing imitation of data loss. Compose ordinarily derives the project name from its directory. Running the same file in a differently named folder can create a perfectly healthy installation with empty volumes. Before creating another admin account or downloading every model again, check docker compose ls and docker volume ls for the original project name. Open WebUI update guidance.
Diagnose an empty model picker or a slow first reply
- The page does not load. Check the host port, the URL and the web service in
docker compose ps. Read the web service startup log before changing the model configuration. No model is needed for the login page to load. - The interface works and the picker is empty. Check
ollama listinside the Ollama service. If the list is empty, finish the model download there. A copy installed by the desktop application on your machine belongs to a different Ollama installation. - The terminal lists a model that the interface cannot see. Check the Ollama connection in the administrator settings. The two containers in the download use
http://ollama:11434. Inside the web container,localhost:11434points back at the web container itself. Save the connection settings and refresh the list. - The first answer takes too long. Run
docker compose exec ollama ollama psto see which model is loaded and how it is running. Available memory, CPU limits and the first load matter. On an Apple Silicon Mac, another arrangement is to run Ollama natively and keep just the interface in Docker. Docker Desktop useshost.docker.internalfor the host, and Ollama must accept connections over that route. Open WebUI connection troubleshooting.
Cost and alternatives
| What you want to do | A good starting point | What you take on |
|---|---|---|
| Try one model on one computer | Ollama CLI | Short terminal test with few moving parts |
| Keep conversations in a browser | Open WebUI with Ollama | Local accounts, two data volumes and backups |
| Work in a desktop application | LM Studio | Choose, download and test models inside the application |
| Get started without maintaining a machine | A hosted chat service | Provider pricing, usage limits and data-handling terms |
There is no commercial API call in this configuration. Your costs are the computer or rented server, electricity, storage and maintenance. As an illustration, an extra 50 watts for eight hours is 0.4 kWh. Multiply by your electricity rate to estimate the bill. Actual power draw depends on the machine. Docker Desktop has its own business subscription terms. If you plan to change the interface branding or sell a managed installation, review Open WebUI's licence for your use case. Docker Desktop terms · Open WebUI licence · LM Studio documentation.
FAQ
Can I use the chat offline?
With the images and a local model already downloaded, a basic text conversation can run without a cloud provider. The project sets Open WebUI to offline mode and disables Ollama's cloud features. Initial downloads and any new models still need a separate way to obtain their files. Open WebUI offline mode.
How much memory does a normal laptop need?
Start with a small model and a short prompt, then measure on the machine you plan to use. Context length, model weights, other running programs and simultaneous requests all affect memory. The size of one download is not a reliable memory requirement for a larger model or an entire team's workload.
Can I switch to a different model later?
Yes. Pull the second model into the same Ollama service, refresh the picker and start a fresh chat. Give each model the same ticket and record what it got right, how long the reply took and whether it added information you never supplied. Those results are much more useful than the number of models in the picker.
Tools
Tools
Tools