Updating Open WebUI Docker Container

If you are running Open WebUI in a Docker container, you will eventually get a message that there is a new update available. Docker containers are immutable, so you need to get the latest image and create a new container (using the same data). This tutorial will show you how to do this without losing any data.

This tutorial will guide you through updating your Open WebUI Docker container by executing commands directly in your terminal.

Prerequisites

  • Docker installed on your system
  • An existing Open WebUI Docker container running

Steps to Update Open WebUI

  1. Open a terminal or command prompt.
  2. Open a web browser and navigate to http://localhost:3000 (or your configured address) to verify that Open WebUI is running with the latest version.

Check the logs of the new container for any issues:

docker logs open-webui

Verify that the new container is running:

docker ps -f name=open-webui

You should see the new container in the list.

Start a new container with the updated image:

docker run -d -p 3000:8080 \
  --add-host=host.docker.internal:host-gateway \
  -v open-webui:/app/backend/data \
  --name open-webui \
  --restart always \
  ghcr.io/open-webui/open-webui:main

Bringing it all together

#!/bin/bash

# Script to update Open WebUI Docker container

# Stop the existing container
echo "Stopping existing Open WebUI container..."
docker stop open-webui

# Remove the existing container
echo "Removing existing Open WebUI container..."
docker rm open-webui

# Pull the latest image
echo "Pulling latest Open WebUI image..."
docker pull ghcr.io/open-webui/open-webui:main

# Run new container with the latest image
echo "Starting new Open WebUI container..."
docker run -d -p 3000:8080 \
  --add-host=host.docker.internal:host-gateway \
  -v open-webui:/app/backend/data \
  --name open-webui \
  --restart always \
  ghcr.io/open-webui/open-webui:main

# Check if the new container is running
if [ $( docker ps -f name=open-webui | wc -l ) -eq 2 ]; then
  echo "Open WebUI container updated and running successfully!"
else
  echo "Error: Open WebUI container failed to start. Please check Docker logs."
fi