You can self-host Ollama and Open WebUI on a VPS with two Docker containers: Ollama serves the models, and Open WebUI gives you a ChatGPT-style interface on top. The size of VPS you need is set by the model, not the web UI. A CPU-only VPS is fine for small models of roughly 1-4 billion parameters. Larger models need more RAM, and anything big and fast needs a GPU server.
This guide covers sizing, a working Docker Compose setup, locking it down so you don't leave an open model API on the internet, and the settings that matter on a small server. Commands and image names below were checked against the official Ollama and Open WebUI docs in November 2026.
What you are actually running
Ollama downloads models and runs inference. It exposes an HTTP API on port 11434. Its Docker docs show a CPU-only container, plus variants for NVIDIA and AMD GPUs.
Open WebUI is the web front end: accounts, chat history, model picker. Its quick start publishes the UI on port 3000 by default and stores data in a Docker volume.
You can also use the all-in-one :ollama Open WebUI image, which bundles Ollama inside the same container. Two separate containers are easier to update and debug, so this guide uses them.

How big a VPS do you need?
Start from the model, because the model has to fit in memory. For a CPU-only VPS, that means system RAM. For GPU inference, it means VRAM.
The download sizes below come from the Ollama model library (as of November 2026). They are the floor for memory use, not the total:
Model tag | Download size | Realistic use on a small VPS |
|---|---|---|
| 1.3 GB | Quick tests, very simple tasks |
| 2.0 GB | Light chat and summarising |
| 2.5 GB | Better quality at a similar footprint |
| 5.2 GB | Needs a larger-RAM server; slow on CPU |
| 9.3 GB | Better on a GPU server |
Plan for more RAM than the file size. The Ollama FAQ explains that memory also scales with context length, and that required RAM grows with OLLAMA_NUM_PARALLEL multiplied by OLLAMA_CONTEXT_LENGTH. You also need room for the operating system, Docker and Open WebUI itself. A sensible rule: pick a server whose RAM is comfortably larger than the model file, then test it.
On CPU, expect slow generation compared with a GPU. The honest way to decide is to run ollama ps after loading your model. Its Processor column shows 100% CPU when the model sits entirely in system memory, and a CPU/GPU split when it is partly offloaded.
Prices change often and differ by provider, so check the pricing pages of the hosts you are comparing instead of trusting a number in a blog post.

Step 1: Install Docker
Install Docker Engine and the Compose plugin using the official Docker instructions for your distribution. Confirm both work:
docker --version
docker compose version Step 2: Write the Compose file
Create a directory and a docker-compose.yml. The Ollama service uses the CPU-only command from the Ollama docs, translated into Compose. The Open WebUI service uses the image, volume and WEBUI_SECRET_KEY from the Open WebUI docs. OLLAMA_BASE_URL points it at the Ollama container.
services:
ollama:
image: ollama/ollama
volumes:
- ollama:/root/.ollama
ports:
- "127.0.0.1:11434:11434"
restart: unless-stopped
open-webui:
image: ghcr.io/open-webui/open-webui:main
ports:
- "127.0.0.1:3000:8080"
volumes:
- open-webui:/app/backend/data
environment:
- OLLAMA_BASE_URL=http://ollama:11434
- WEBUI_SECRET_KEY=${WEBUI_SECRET_KEY}
depends_on:
- ollama
restart: unless-stopped
volumes:
ollama:
open-webui: Two details matter here:
Binding to
127.0.0.1. The Ollama docs use-p 11434:11434. On a public server, publishing a port that way can make it reachable from the internet, and Ollama has no login of its own. Binding to127.0.0.1keeps both ports private to the server. Your reverse proxy will be the only public entry point.A fixed secret key. The Open WebUI docs warn that without a persistent
WEBUI_SECRET_KEY, everyone is logged out whenever the container is recreated. Generate one and put it in a.envfile next to the Compose file:
echo "WEBUI_SECRET_KEY=$(openssl rand -hex 32)" > .env
chmod 600 .env
docker compose up -d Step 3: Pull a model
Run a model inside the Ollama container, as the Ollama docs show for Docker:
docker compose exec ollama ollama run llama3.2:3b This downloads the model on first use, then opens a prompt. Type a message to confirm it responds, then exit. To check where the model is loaded:
docker compose exec ollama ollama ps Step 4: Put HTTPS in front
Don't expose port 3000 directly to the internet. Use a reverse proxy such as Caddy or Nginx on the host, with a DNS name pointing at your server and a TLS certificate. A minimal Caddyfile, assuming you installed Caddy from its official docs, looks like this:
chat.example.com {
reverse_proxy 127.0.0.1:3000
} Caddy's automatic HTTPS is designed to obtain certificates for the domain once DNS points at the server and ports 80 and 443 are reachable. Replace chat.example.com with your own domain. Its reverse_proxy directive also covers streaming connections such as WebSockets. If you use Nginx instead, check that streaming and WebSocket connections work after setup.
Step 5: Create the admin account and lock sign-ups
Open your domain in a browser. The first screen offers Create Admin Account, and that first account is the administrator. Per the Open WebUI quick start, sign-up switches itself off once the admin account exists. To let other people join, turn on New Sign Ups under your avatar > Settings > Admin > Authentication; new accounts then wait as Pending until you approve them in the Admin Panel. Menu names can change between releases, so check the Open WebUI documentation for your version.
Tuning for a small server
These settings come from the Ollama FAQ and are set as environment variables on the ollama service:
OLLAMA_KEEP_ALIVE: by default models stay loaded for 5 minutes after the last request. On a small server you may want to unload sooner to free RAM, or keep a model loaded permanently (-1) so the first reply is not slow.OLLAMA_NUM_PARALLEL: defaults to 1. Raising it lets several users chat at once, but memory use scales with it.OLLAMA_MAX_LOADED_MODELS: limits how many models sit in memory together. Keep it low if RAM is tight.OLLAMA_FLASH_ATTENTIONand K/V cache quantization: with Flash Attention enabled, quantizing the K/V cache toq8_0uses roughly half the memory of the defaultf16, according to the FAQ, with a very small loss in precision.
In Compose, add them like this:
ollama:
environment:
- OLLAMA_KEEP_ALIVE=10m
- OLLAMA_NUM_PARALLEL=1 Updating and backing up
Update both containers with:
docker compose pull
docker compose up -d Your chats and settings live in the open-webui volume, and downloaded models live in the ollama volume. Back up the Open WebUI volume before major updates. Never delete it casually, since the Open WebUI docs note that removing the volume deletes all data.
When a VPS is the wrong tool
A CPU VPS is a good fit for private experiments, small models, and teams that mainly want their data on their own server. If you need fast answers from large models for many users, you need GPU hardware, and Ollama's Docker docs cover the NVIDIA Container Toolkit setup for that. If you only need occasional access to a strong model, a hosted API may be cheaper than running a server around the clock.
FAQ
Can I run Ollama on a VPS without a GPU? Yes. The official Docker image has a CPU-only mode. Generation is slower than on a GPU, so stick to smaller models and test response time with your real prompts.
Is Ollama's API safe to expose to the internet?
Not as-is. Ollama binds to 127.0.0.1 by default and has no built-in authentication. Keep it private, as in the Compose file above, and let Open WebUI behind an HTTPS proxy be the only public service.
Do I need the Open WebUI :ollama image?
No. It bundles Ollama into one container, which is simpler to start but couples the two. Separate containers let you update and restart each independently.
How do I keep a model loaded so replies start quickly?
Set OLLAMA_KEEP_ALIVE=-1, or send keep_alive with your API request. The Ollama FAQ documents both. The trade-off is that the model holds RAM permanently.
Where is my data stored?
In two Docker volumes: ollama for models and open-webui for chats, users and settings. Back up the second one before updates.
Need help with the setup?
If you would rather have this running without the trial and error, Kavio can set up and harden a private AI server for your team, or build the custom tools around it. See our services or get in touch. If you are new to servers, our guide to what a VPS is (in Vietnamese) explains the basics, and our n8n self-hosting guide pairs well with a private model for automation workflows.

