Odoo with Docker Persistent File Storage Guide - Sync Data Files with Host Machine / Local Device
- John Julius Danker Khoo
- Jul 5
- 1 min read
Why do we need persisitent file storage?
By default, Docker containers are isolated. To make data written inside a container (e.g., uploads, logs, exports) persist and reflect on the host machine, you need volume mapping. This is crucial for:
File persistence across container restarts
Easy access to data for backups or debugging
Sharing files between host and container in real-time
Basics with Docker Guide: Syncing Container and Host File Storage
File structure
project/
├── docker/
│ └── storage/ # Data written here should be visible on host
├── docker-compose.yml
├── Dockerfile
DockerFile
FROM python:3.10-slim
WORKDIR /app
COPY . /app
CMD ["python3", "-u", "app.py"]
docker-compose.yml
version: '3.9'
services:
app:
build: .
volumes:
- ./docker/storage:/app/storage # Host:Container mapping
sampleapp.py
with open("storage/output.txt", "w") as f:
f.write("This file is shared with the host machine.")
run
docker-compose up --build
Odoo with Docker
In Odoo deployments, persistent storage is critical for:
File uploads (attachments, product images)
Generated reports (PDFs, CSVs)
Log files and temporary data
DockerFile
VOLUME ["/mnt/filestore"]
docker-compose.yml
services:
odoo:
image: odoo:18
volumes:
- ./filestore:/mnt/filestore # Custom storage
Summary
Volume mapping bridges your Odoo container with your local filesystem, enabling persistent, accessible, and backup-ready file handling. Critical for development, debugging, and production-grade setups.
Commentaires