top of page

How to Set Up Odoo 18 Server Using Docker on Linux (Quick setup in 4 Steps)

  • Writer: John Julius Danker  Khoo
    John Julius Danker Khoo
  • May 23
  • 2 min read

Updated: Jun 11

Why Use Docker?


  1. Bundling Dependencies: Docker enables the packaging of Odoo with all its required components and dependencies.

  2. Isolation: Containerization provides isolation, preventing conflicts with other software installed on the system.

  3. Industry Adoption: Considered as a crucial tool by developers.

  4. Consistency: Docker facilitates consistent management across various environments.

  5. Simplified Management: Docker streamlines the overall management of Odoo deployments.


Prerequisites


Before you can start setting up Odoo, ensure you have these essentials:


  • A Linux distribution ( Ubuntu 22.04 is done in this setup)

  • Docker and Docker Compose installed on your machine

  • Basic knowledge of how to use terminal commands


Docker installation, simply run the following commands in your terminal:

sudo apt update
sudo apt install docker.io
sudo systemctl start docker
sudo systemctl enable docker 

To install Docker Compose:

sudo apt install docker-compose


Step 1: Create a Directory for Odoo


Next, create a directory to store all the essential files and configurations for Odoo. This keeps everything clean and manageable.

mkdir ~/odoo-docker
cd ~/odoo-docker


Step 2: Create a Docker Compose File


The `docker-compose.yml` file is crucial for your setup. It defines how the services will run. Create this file inside the `~/odoo-docker` directory.


Here’s a basic example of what this file should include:

Reference files

in the docker-compose.yml file

Make adjustment to port and container name as shown below

version: '3.7'
services:
   
  odoo:
    image: odoo:18
    container_name: odoo-linux
    build: .  
    ports:
      - "8069:8069"  # Odoo web interface will be available on port 8069
    environment:
      - HOST=db 
      - USER=odoo 
      - PASSWORD=odoo 
      - DB_NAME=odoo  # Specify the database name
    volumes:
      - ./custom/addons:/mnt/extra-addons  # Mount your custom addons
      - odoo-data:/var/lib/odoo  # Persistent Odoo data
    depends_on:
      db:
        condition: service_healthy  # Wait for the database to be healthy
    networks:
      - odoo-net
    command: >  
      odoo --xmlrpc-port=8069  --init=base --load=base  --database=odoo
    healthcheck:
      test: ["CMD-SHELL", "curl -f http://localhost:8069 || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 5
  db:
    image: postgres:15
    container_name: odoo-db-linux
    environment:
      - POSTGRES_DB=odoo
      - POSTGRES_USER=odoo
      - POSTGRES_PASSWORD=odoo
    volumes:
      - odoo-db-data:/var/lib/postgresql/data
    networks:
      - odoo-net
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U odoo"]
      interval: 30s
      timeout: 10s
      retries: 5
volumes:
  odoo-data:
  odoo-db-data:
networks:
  odoo-net:
    driver: bridge

Explanation of the Compose File


  • Web Service (odoo): This section runs the Odoo application, linking it to the database. It exposes port 8069, which is Odoo's default, allowing you to easily access the application.

  • Database Service (db): This part sets up the PostgreSQL database that Odoo uses. I've specified essential environment variables for user, password, and database name. PostgreSQL is a reliable choice, with 65% of developers favoring it in database selections.

Step 3: Start the Containers


With your `docker-compose.yml` file ready, start your services with one command:


docker-compose up -d

The `-d` flag means that the containers will run in the background, allowing you to keep using your terminal.


Step 4: Access Odoo


After starting the services, open your web browser and navigate to `http://localhost:8069`. You should see the Odoo setup screen, ready for your next steps.

Default Email: admin Password: admin


Login Page
Login Page

Stopping the Service


When your session is over or if you need to stop the services, simply execute:

docker-compose down 

This command will stop and remove the containers and network as defined in your `docker-compose.yml` file, cleaning up your environment.


Comments


Subscribe Form

  • facebook
  • linkedin

©2019 by Excelroot Technology Sdn Bhd.

bottom of page