How to Deploy Ollama, Open WebUI, and AUTOMATIC1111 Stable Diffusion via Docker on a VPS (CPU‑Only)

How to Deploy Ollama, Open WebUI, and AUTOMATIC1111 Stable Diffusion via Docker on a VPS (CPU‑Only)

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 with sudo 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

  1. Create a project directory

    mkdir ~/ollama-webui && cd ~/ollama-webui
    
  2. Create a docker-compose.yml

    nano docker-compose.yml
    
  3. 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
    
  4. Launch the stack

    docker-compose up -d
    
  5. Access the interface
    Open your browser to http://<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)

  1. Create a new directory

    mkdir ~/sd && cd ~/sd
    
  2. Add your docker-compose.yml

    nano docker-compose.yml
    
  3. 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
    
  4. Start it up

    docker-compose up -d
    
  5. 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!

Back to blog
  • ChatGPT Uncovered Podcast

    ChatGPT Uncovered Podcast

    Pedro Martins

    ChatGPT Uncovered Podcast ChatGPT Uncovered Podcast Exploring the Frontiers of AI Conversational Models Episode 1: Understanding ChatGPT Published on: May 15, 2023 Your browser does not support the audio element....

    ChatGPT Uncovered Podcast

    Pedro Martins

    ChatGPT Uncovered Podcast ChatGPT Uncovered Podcast Exploring the Frontiers of AI Conversational Models Episode 1: Understanding ChatGPT Published on: May 15, 2023 Your browser does not support the audio element....

  • Power Apps In-Depth Podcast

    Power Apps In-Depth Podcast

    Pedro Martins

    Power Apps In-Depth Podcast Power Apps In-Depth Podcast Exploring the Capabilities of Microsoft Power Apps Episode 1: Introduction to Power Apps Published on: April 20, 2023 Your browser does not...

    Power Apps In-Depth Podcast

    Pedro Martins

    Power Apps In-Depth Podcast Power Apps In-Depth Podcast Exploring the Capabilities of Microsoft Power Apps Episode 1: Introduction to Power Apps Published on: April 20, 2023 Your browser does not...

  • Exploring Power Pages Podcast

    Exploring Power Pages Podcast

    Pedro Martins

    Exploring Power Pages Podcast Exploring Power Pages Podcast Delving into the World of Microsoft Power Pages Episode 1: Getting Started with Power Pages Published on: March 10, 2023 Your browser...

    Exploring Power Pages Podcast

    Pedro Martins

    Exploring Power Pages Podcast Exploring Power Pages Podcast Delving into the World of Microsoft Power Pages Episode 1: Getting Started with Power Pages Published on: March 10, 2023 Your browser...

1 of 3