How to Deploy Ollama, Open WebUI, and AUTOMATIC1111 Stable Diffusion via Docker on a VPS (CPU‑Only)
By Pedro Martins, April 20, 2025
Running your own private AI stack in the cloud has never been easier—even if you don’t have a GPU. In this post, I’ll walk you through deploying:
- Ollama for LLM inference (e.g. LLaMA 3)
- Open WebUI as a sleek browser-based chat interface
- AUTOMATIC1111 Stable Diffusion WebUI for text-to-image generation
All on an Ubuntu VPS (22.04+) with Docker and Docker Compose, on CPU only.
Prerequisites
Before we get started, make sure you have:
- An Ubuntu 22.04 (or newer) VPS
- Docker and Docker Compose installed
- Ports 11434, 3000, and 7860 open in your firewall
-
root
access or a user withsudo
privileges
Step 1: Install Docker & Docker Compose
sudo apt update && sudo apt install -y docker.io curl git
# If docker-compose plugin isn’t available, install manually:
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" \
-o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
Verify both are installed:
docker --version
docker-compose --version
Step 2: Deploy Ollama + Open WebUI
-
Create a project directory
mkdir ~/ollama-webui && cd ~/ollama-webui
-
Create a
docker-compose.yml
nano docker-compose.yml
-
Paste the following:
version: "3.8" services: ollama: image: ollama/ollama container_name: ollama ports: - "11434:11434" networks: - ollama-net restart: always open-webui: image: ghcr.io/open-webui/open-webui:main container_name: open-webui ports: - "3000:8080" environment: - OLLAMA_API_BASE_URL=http://ollama:11434 depends_on: - ollama networks: - ollama-net restart: always networks: ollama-net: driver: bridge
-
Launch the stack
docker-compose up -d
-
Access the interface
Open your browser tohttp://<YOUR_VPS_IP>:3000
Step 3: Download the LLaMA 3 Model
With the containers running, pull the 8‑billion‑parameter model:
docker exec -it ollama ollama pull llama3:8b
Ollama will cache it locally for inference.
Step 4: Install AUTOMATIC1111 Stable Diffusion WebUI (CPU Mode)
-
Create a new directory
mkdir ~/sd && cd ~/sd
-
Add your
docker-compose.yml
nano docker-compose.yml
-
Use this configuration:
version: '3.8' services: sd-webui: image: goolashe/automatic1111-sd-webui container_name: sd-webui ports: - "7860:7860" volumes: - ./outputs:/stable-diffusion-webui/outputs environment: - CLI_ARGS=--skip-torch-cuda-test --no-half --use-cpu all --precision full --lowvram restart: always
-
Start it up
docker-compose up -d
-
Browse to
http://<YOUR_VPS_IP>:7860
Step 5: Test a Prompt
In the Stable Diffusion UI, try a lightweight prompt for faster CPU performance:
a futuristic city at night, cyberpunk style, neon lights, rain, 512x512
Tip: Stick to 512×512 or smaller to keep generation times reasonable.
Step 6: Access Your Images
All generated images land in ~/sd/outputs
. You can:
- Download via SFTP/SCP
- Serve them with a lightweight Nginx gallery
Conclusion
Congratulations! 🎉 You now have a self‑hosted AI playground:
- Chat with LLaMA 3 via Open WebUI
- Generate images with Stable Diffusion
- Secure, private, and fully under your control
Feel free to share this post or adapt the setup for your own projects. Happy self‑hosting!