Skip to main content

Running Odoo in a Docker container

A quick and straightforward approach to running Odoo in a Docker container, updated for Odoo v15.

A quick and straightforward approach to running Odoo

Since I prefer keeping workstations in pristine condition, I often opt for running applications through Docker rather than installing them natively. This article provides a straightforward guide to setting up a Docker-based Odoo environment.

Prerequisites

  • Docker and Docker Compose installed on your system
  • Basic understanding of container concepts
  • Familiarity with YAML configuration files

Note

*This guide has been updated for Odoo v15.*

Docker compose configuration

Sample docker-compose.yml file for a basic setup with persistent volumes for both Odoo configuration and PostgreSQL database:

version: '3.1'
services:
  web:
    image: odoo:15.0
    depends_on:
      - db
    ports:
      - "8069:8069"
    volumes:
      - odoo-web-data:/var/lib/odoo
      - ./config:/etc/odoo
      - ./addons:/mnt/extra-addons
  db:
    image: postgres:15
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=odoo
      - POSTGRES_PASSWORD=odoo
      - PGDATA=/var/lib/postgresql/data/pgdata
    volumes:
      - odoo-db-data:/var/lib/postgresql/data/pgdata
volumes:
  odoo-web-data:
  odoo-db-data:

Ensure that the ./config directory contains an odoo.conf file with the addons_path:

[options]
addons_path = /mnt/extra-addons

Container management

Starting the environment

Bring the container into action with:

docker-compose up -d

Stopping the environment

Stop the container with:

docker-compose stop

Accessing Odoo

The Odoo interface is available at:

http://localhost:8069/

Managing persistent data

Locating volume data

To find out where Docker mounts our data, use:

docker volume inspect odoo_odoo-db-data

This returns a path such as:

"Mountpoint": "/var/lib/docker/volumes/odoo_odoo-db-data/_data"

Removing volumes

Warning

Only perform these steps when you're prepared to have your data deleted. This operation cannot be undone.

To remove Odoo application data:

docker volume rm odoo_odoo-web-data

To remove PostgreSQL database data:

docker volume rm odoo_odoo-db-data

Database initialisation

Setting the master password

Odoo generates a master password for database management with the option to override it. This master password should be stored securely as it provides administrative access to your Odoo instance.

Demo data

Odoo offers the option to pre-populate the database with demo data. For more advanced database population options, consider Odoo's CLI functionality.

Developer features

When testing or developing for Odoo, activate the Developer Mode through one of these methods:

  • Modify the URL directly to include debug=1
  • Open the command palette (ctrl+k) and type debug
  • Follow other approaches from the Odoo v15 Manual: Developer Mode

Custom applications

Custom applications can be placed in the ./addons directory that we configured as a persistent volume. If Docker cannot read this directory, you may need to adjust its permissions.

To verify Docker's access to the directory:

# Assuming the Odoo container is called odoo_web_1
docker exec -it odoo_web_1 ls -alG mnt/extra-addons

Production considerations

When implementing this setup in a production environment, consider using Docker secrets for secure credential management.

Further improvements

Consider setting up a secondary PostgreSQL server for automatic backups. For reference, see dorucioclea/odoo-config/blob/main/docker-compose.yml.

Resources