lobehub/docs/self-hosting/platform/docker-compose.mdx
René Wang 3dfc86fd0f
feat: Update user guide & changelog (#11518)
* feat: Redesign doc

* chore: uopdate site

* chore: uopdate site

* chore: uopdate site

* chore: uopdate site

* chore: uopdate site

* feat: Uopdate content

* chore: New doc

* chore: Update content

* chore: Update content

* chore: add images

* chore: add images

* chore: add images

* chore: add images

* feat: Add more images

* feat: Add more images

* fix: Cannot reach end

* chore: Update content

* chore: Update content

* chore: Update content

* chore: Update content

* chore: Update content

* Revise README content and structure

Updated README to reflect changes in project description and removed outdated notes.

* Revise 'Getting Started' and TOC in README

Updated the 'Getting Started' section and modified the table of contents.

* chore: Update content

* Revise README structure and content

Updated the Getting Started section and removed the Table of Contents. Adjusted the Local Development instructions.

* Remove custom themes section from README

Removed section about custom themes from README.

* Update README.md

* Refine introduction and highlight cloud version

Updated wording for clarity and added recommendation for cloud version.

* chore: Update content

* chore: Update content

* chore: Update content

* chore: Update content

* chore: Update content

* chore: Update content

* chore: Update content

* fix: add missing translation

* 🔀 chore: Move README changes to feat/readme branch

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: add missing translation

* chore: update cdn

* docs: add migration guide from v1.x local database to v2.x and update help sections

Signed-off-by: Innei <tukon479@gmail.com>

* fix: add missing translation

* fix: add missing images

* fix: add missing changelogs

* fix: add missing changelogs

* fix: add missing changelogs

* fix: add missing changelogs

* fix: add missing changelogs

* style: update cdn

---------

Signed-off-by: Innei <tukon479@gmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: canisminor1990 <i@canisminor.cc>
Co-authored-by: Innei <tukon479@gmail.com>
2026-01-26 15:28:33 +08:00

132 lines
3.9 KiB
Text

---
title: Deploy LobeHub with Docker Compose
description: >-
Learn how to deploy the LobeHub service using Docker Compose. Follow
step-by-step instructions to install Docker, run the deployment command, and
set up automatic updates.
tags:
- Docker Compose
- LobeHub Service
- Docker Deployment
- Automatic Updates
- Crontab Script
---
# Docker Compose Deployment Guide
<div style={{display:"flex", gap: 4}}>
[![][docker-release-shield]][docker-release-link]
[![][docker-size-shield]][docker-size-link]
[![][docker-pulls-shield]][docker-pulls-link]
</div>
We provide a [Docker image][docker-release-link] for deploying the LobeHub service on your private device.
<Steps>
### Install Docker Container Environment
(Skip this step if already installed)
<Tabs items={['Ubuntu', 'CentOS']}>
<Tab>
```fish
$ apt install docker.io
```
</Tab>
<Tab>
```fish
$ yum install docker
```
</Tab>
</Tabs>
### Run Docker Compose Deployment Command
When using `docker-compose`, the configuration file is as follows:
```yml
version: '3.8'
services:
lobe-chat:
image: lobehub/lobe-chat
container_name: lobe-chat
restart: always
ports:
- '3210:3210'
environment:
OPENAI_API_KEY: sk-xxxx
OPENAI_PROXY_URL: https://api-proxy.com/v1
```
Run the following command to start the Lobe Chat service:
```bash
$ docker-compose up -d
```
### Crontab Automatic Update Script (Optional)
Similarly, you can use the following script to automatically update Lobe Chat. When using `Docker Compose`, no additional configuration of environment variables is required.
```bash
#!/bin/bash
# auto-update-lobe-chat.sh
# Set proxy (optional)
export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890
# Pull the latest image and store the output in a variable
output=$(docker pull lobehub/lobe-chat:latest 2>&1)
# Check if the pull command was executed successfully
if [ $? -ne 0 ]; then
exit 1
fi
# Check if the output contains a specific string
echo "$output" | grep -q "Image is up to date for lobehub/lobe-chat:latest"
# If the image is already up to date, do nothing
if [ $? -eq 0 ]; then
exit 0
fi
echo "Detected Lobe-Chat update"
# Remove the old container
echo "Removed: $(docker rm -f Lobe-Chat)"
# You may need to navigate to the directory where `docker-compose.yml` is located first
# cd /path/to/docker-compose-folder
# Run the new container
echo "Started: $(docker-compose up)"
# Print the update time and version
echo "Update time: $(date)"
echo "Version: $(docker inspect lobehub/lobe-chat:latest | grep 'org.opencontainers.image.version' | awk -F'"' '{print $4}')"
# Clean up unused images
docker images | grep 'lobehub/lobe-chat' | grep -v 'lobehub/lobe-chat-database' | grep -v 'latest' | awk '{print $3}' | xargs -r docker rmi > /dev/null 2>&1
echo "Removed old images."
```
This script can also be used in Crontab, but ensure that your Crontab can find the correct Docker command. It is recommended to use absolute paths.
Configure Crontab to execute the script every 5 minutes:
```bash
*/5 * * * * /path/to/auto-update-lobe-chat.sh >> /path/to/auto-update-lobe-chat.log 2>&1
```
</Steps>
[docker-pulls-link]: https://hub.docker.com/r/lobehub/lobe-chat
[docker-pulls-shield]: https://img.shields.io/docker/pulls/lobehub/lobe-chat?color=45cc11&labelColor=black&style=flat-square
[docker-release-link]: https://hub.docker.com/r/lobehub/lobe-chat
[docker-release-shield]: https://img.shields.io/docker/v/lobehub/lobe-chat?color=369eff&label=docker&labelColor=black&logo=docker&logoColor=white&style=flat-square&sort=semver
[docker-size-link]: https://hub.docker.com/r/lobehub/lobe-chat
[docker-size-shield]: https://img.shields.io/docker/image-size/lobehub/lobe-chat?color=369eff&labelColor=black&style=flat-square&sort=semver