Running OCS Inventory Server with Docker
This guide explains how to deploy OCS Inventory (backend API + web console) using Docker Compose. It uses the official ocsinventory-server Docker stack, which brings up four containers:
ocsinventory-backend
ocsinventory/ocsinventory-backend
Django REST API (served over uWSGI)
ocsinventory-proxy
nginx
Reverse proxy in front of the backend, exposes ports 80/443
ocsinventory-db
postgres:15.15
PostgreSQL database used by the backend
ocsinventory-frontend
ocsinventory/ocsinventory-frontend
Web console, exposed on port 8080
1. Requirements
Docker Engine (20.10 or newer)
Docker Compose plugin (
docker compose)Ports
80,443and8080available on the host (or adjust them, see Changing exposed ports)
2. Get the stack
Download the docker-compose.yml and the files/ directory for the version you want to deploy:
mkdir ocsinventory-server && cd ocsinventory-server
curl -O https://raw.githubusercontent.com/OCSInventory-NG/OCSInventory-Server-Packages/main/ocsinventory-server/docker/3.0.0-rc1/docker-compose.yml
mkdir -p files/nginx
curl -o files/nginx/ocsinventory-backend.conf \
https://raw.githubusercontent.com/OCSInventory-NG/OCSInventory-Server-Packages/main/ocsinventory-server/docker/3.0.0-rc1/files/nginx/ocsinventory-backend.conf3. Configure the stack
Before starting the stack for the first time, review and adjust the environment variables in docker-compose.yml.
Database credentials
The ocsinventory-db and ocsinventory-backend services must agree on the same PostgreSQL credentials:
Public URLs
Two variables need to match how you will actually reach the stack from a browser:
ocsinventory-backend.FRONTEND_REDIRECT_ENV- URL where the web console is reachable (used by the backend, e.g. for redirects).ocsinventory-frontend.BACKEND_API_ROUTE_ENV- URL where the backend API is reachable (used by the console to call the API).
By default they are set for a local deployment:
If you deploy behind a domain name (e.g. ocsinventory.example.com), update both accordingly, for instance:
Backend debug mode
DEBUG_ENV controls Django's debug mode. Keep it set to "False" in production; only set it to "True" for troubleshooting, as debug mode can leak sensitive information.
4. Start the stack
On first startup:
ocsinventory-dbinitializes its data directory and runs a healthcheck before the backend starts.ocsinventory-backendgenerates its configuration (.env) from the environment variables above, generates a Django secret key, and runs database migrations automatically.ocsinventory-proxystarts once the backend is up, exposing the API on ports 80/443.ocsinventory-frontendstarts and serves the web console on port 8080.
Check that every container is healthy:
Follow the logs (useful the first time, to confirm migrations succeeded):
5. Access OCS Inventory
Web console:
http://localhost:8080(or the host/port you configured)Backend API:
http://localhost/(or the host/port you configured)
6. Data persistence
The stack uses named Docker volumes so data survives container restarts and recreations:
ocsinventory-db
PostgreSQL data files
ocsinventory-backend-socket
UNIX socket shared between backend and proxy
ocsinventory-frontend-config
Web console configuration
ocsinventory-frontend-extensions
Web console extensions/plugins
List them:
7. Common operations
Stop the stack (keep data)
Stop the stack and delete all data
Update to a newer version
Update the
image:tags indocker-compose.ymlto the new version (backend and frontend versions should generally match).Pull the new images and recreate the containers:
Database migrations are applied automatically by the backend's entrypoint on startup.
Back up the database
Restore the database
8. Changing exposed ports
If ports 80, 443 or 8080 are already in use on the host, change the left side of the ports: mapping in docker-compose.yml, for example:
Remember to update FRONTEND_REDIRECT_ENV and BACKEND_API_ROUTE_ENV (see Public URLs) so they reflect the ports you actually expose.
9. Enabling HTTPS
The ocsinventory-proxy service exposes port 443, but TLS termination is not configured out of the box. To enable HTTPS:
Provide a certificate and key on the host (e.g. via Let's Encrypt).
Mount them into the
ocsinventory-proxycontainer and extendfiles/nginx/ocsinventory-backend.confwith aserverblock listening on443 sslthat references those files, redirecting plain HTTP to HTTPS if desired.Update
FRONTEND_REDIRECT_ENVandBACKEND_API_ROUTE_ENVto usehttps://.
10. Troubleshooting
Backend keeps restarting - check
docker compose logs ocsinventory-backend. This is usually a database connectivity issue (wrong credentials, orocsinventory-dbnot yet healthy) or a failed migration.502/504 errors from the proxy - the backend is not ready yet, or crashed. Check its logs, and confirm
ocsinventory-backend-socketis correctly shared between theocsinventory-backendandocsinventory-proxycontainers.Console cannot reach the API - confirm
BACKEND_API_ROUTE_ENVon the frontend matches the URL actually used to reach the backend from the browser (not from inside the Docker network).
Last updated

