How to Set Up an Odoo 18 Instance Using Docker and Docker Compose

Odoo is a popular open-source ERP system that integrates various business applications into one cohesive platform.

Setting up an Odoo instance manually can be time-consuming and error-prone. With Docker and Docker Compose, you can simplify the process and ensure a smooth deployment. In this guide, we’ll walk you through the steps to set up Odoo 18 with PostgreSQL using Docker and Docker Compose.


Why Use Docker and Docker Compose?

Using Docker simplifies application deployment by encapsulating everything in containers. Docker Compose further enhances this by allowing you to define and manage multi-container applications easily.

For our Odoo 18 setup, we’ll use Docker Compose to manage:

  1. A PostgreSQL database for storing Odoo data.

  2. An Odoo web service built from a custom Dockerfile.


Prerequisites

Before starting, ensure you have the following installed on your system:

  • Docker

  • Docker Compose


Project Setup

Here’s the configuration we’ll use for Odoo 18.

1. docker-compose.yml

This file defines two services:

  • db: Runs the PostgreSQL database container.

  • odoo_web: Runs the Odoo web service container.

services:
  db:
    image: postgres:16
    ports:
      - "5432:5432" 
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=odoo18
      - POSTGRES_PASSWORD=odoo
    volumes:
      - odoo18-db-data:/var/lib/postgresql/data

  odoo_web:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "8069:8069"
    environment:
      - DB_HOST=db
      - DB_PORT=5432
      - DB_USER=odoo18
      - DB_PASSWORD=odoo
    volumes:
      - ./customs:/customs
      - ./odoo.conf:/etc/odoo/odoo.conf
      - odoo18-web-data:/var/lib/odoo

volumes:
  odoo18-web-data:
  odoo18-db-data:

2. odoo.conf

This file contains configuration settings for the Odoo instance, such as database credentials, addons paths, and system limits.

[options]
addons_path = /usr/lib/python3/dist-packages/odoo/addons,/customs
admin_passwd = pass1234
db_host = db
db_port = 5432
db_user = odoo18
db_password = odoo
limit_time_cpu = 1200
limit_time_real = 1800

3. Dockerfile

The Dockerfile builds the Odoo web service image, exposing the required port and specifying the command to run Odoo.

FROM odoo:18  
EXPOSE 8069  
CMD ["odoo"]

Step-by-Step Instructions

Step 1: Set Up the Project Directory

Create a project folder and add the following files:

  • docker-compose.yml

  • Dockerfile

  • odoo.conf

  • A customs/ folder for custom Odoo modules.

Your directory should look like this:

plaintextCopyEdit.  
├── Dockerfile  
├── docker-compose.yml  
├── customs/  
└── odoo.conf

Step 2: Build and Start the Containers

Run the following command to build and start the containers in detached mode:

docker compose up -d

This will:

  1. Pull the PostgreSQL and Odoo 18 images.

  2. Build the Odoo web service image from the Dockerfile.

  3. Start both containers.

Step 3: Access Odoo

Once the services are running, open your browser and visit:

http://localhost:8069

You’ll see the Odoo setup page where you can configure and log in to your instance.


Conclusion

Congratulations! You’ve successfully set up an Odoo 18 instance with Docker and Docker Compose. This setup provides a modular, scalable, and portable development environment, making it easier to manage and customize your Odoo projects.

0
Subscribe to my newsletter

Read articles from Ahmed Houssam BOUZINE directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ahmed Houssam BOUZINE
Ahmed Houssam BOUZINE

Tech enthusiast with a strong focus on Linux, Java, Rust, Cloud, and DevOps. Passionate about hackathons, I proudly represented Morocco in the global Google Solution Challenge 2024 and Africa in the Silicon Valley Hackathon, striving to make a meaningful impact in technology and the Moroccan tech community.