top of page

Odoo with Docker Persistent File Storage Guide - Sync Data Files with Host Machine / Local Device

  • Writer: John Julius Danker  Khoo
    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

  1. File structure

project/
├── docker/
│   └── storage/   # Data written here should be visible on host
├── docker-compose.yml
├── Dockerfile
  1. DockerFile

FROM python:3.10-slim

WORKDIR /app

COPY . /app

CMD ["python3", "-u", "app.py"] 
  1. docker-compose.yml


version: '3.9'

services: 
  app: 
    build: . 
    volumes:

      - ./docker/storage:/app/storage  # Host:Container mapping
  1. sampleapp.py

with open("storage/output.txt", "w") as f:
    f.write("This file is shared with the host machine.")
  1. 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


  1. DockerFile

    VOLUME ["/mnt/filestore"]
  1. 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


Subscribe Form

  • facebook
  • linkedin

©2019 by Excelroot Technology Sdn Bhd.

bottom of page