📜  odoo 14 docker compose (1)

📅  最后修改于: 2023-12-03 15:18:05.771000             🧑  作者: Mango

Odoo 14 Docker Compose

Introduction

Odoo is an open-source business application suite that includes numerous components for various business functions such as accounting, CRM, inventory management, etc. Odoo provides an extensive library of modules that developers can use to build customized business applications.

Docker Compose is a tool for defining and running multi-container Docker applications. It allows you to define your application's services, networks, volumes, and other dependencies in a single YAML file, making it easy to manage and deploy multiple containers as an application.

In this tutorial, we will show you how to set up an Odoo 14 instance using Docker Compose.

Prerequisites

Before you begin, make sure you have the following prerequisites:

  • Docker installed on your system
  • Docker Compose installed on your system
Step 1: Create a Docker Compose file

First, you need to create a Docker Compose file to define the services and dependencies for your Odoo application.

Create a new directory for your Odoo application and create a new docker-compose.yml file inside it:

mkdir odoo-14
cd odoo-14
touch docker-compose.yml

Open the docker-compose.yml file in your favorite editor and paste the following configuration:

version: "3"
services:
  db:
    image: postgres:12
    environment:
      POSTGRES_PASSWORD: mysecretpassword
      POSTGRES_USER: odoo
      POSTGRES_DB: odoo
    volumes:
      - odoo-db-data:/var/lib/postgresql/data
  odoo:
    depends_on:
      - db
    image: odoo:14
    environment:
      DB_HOST: db
      DB_PORT: 5432
      DB_USER: odoo
      DB_PASSWORD: mysecretpassword
      DB_NAME: odoo
    ports:
      - "8069:8069"
    volumes:
      - odoo-data:/var/lib/odoo
volumes:
  odoo-db-data:
  odoo-data:

Here, we have defined two services:

  • db - This service uses the postgres:12 image to set up a PostgreSQL database for our Odoo instance. We have also defined some environment variables to set the PostgreSQL database's password, username, and database name. We have also defined a named volume odoo-db-data for the PostgreSQL data.
  • odoo - This service uses the odoo:14 image to set up our Odoo instance. We have defined some environment variables to set the database connection details for the Odoo instance. We have also defined a named volume odoo-data for the Odoo data.

The depends_on option in the odoo service is used to specify that this service depends on the db service, which means that the db service will be started first.

We have also exposed port 8069 of the odoo service so that we can access the Odoo instance via web browser.

Step 2: Start the Odoo instance

Now that we have defined our Docker Compose file, let's start our Odoo instance.

Open a terminal and navigate to the odoo-14 directory where you created the docker-compose.yml file, and run the following command:

docker-compose up

This will start the Odoo instance, and you should see some logs in your terminal indicating that Odoo is starting up:

Creating network "odoo-14_default" with the default driver
Creating volume "odoo-14_odoo-db-data" with default driver
Creating volume "odoo-14_odoo-data" with default driver
Creating odoo-14_db_1 ... done
Creating odoo-14_odoo_1 ... done
Attaching to odoo-14_db_1, odoo-14_odoo_1
odoo_1  | 2021-06-04 09:30:37,861 1 INFO ? odoo: Odoo version 14.0-20210603
odoo_1  | 2021-06-04 09:30:37,862 1 INFO ? odoo: Using configuration file at /etc/odoo/odoo.conf
odoo_1  | 2021-06-04 09:30:37,862 1 INFO ? odoo: addons paths: ['/usr/lib/python3/dist-packages/odoo/addons', '/mnt/extra-addons']
odoo_1  | 2021-06-04 09:30:37,862 1 INFO ? odoo: database: odoo@db:5432
odoo_1  | 2021-06-04 09:30:37,973 1 INFO ? odoo.addons.base.models.ir_actions_report: You need Wkhtmltopdf to print a pdf version of the reports.
odoo_1  | 2021-06-04 09:30:38,033 1 INFO ? odoo.service.server: HTTP service (werkzeug) running on 0.0.0.0:8069

Once the logs indicate that Odoo is running, open your web browser and navigate to http://localhost:8069. You should see the Odoo login page.

Conclusion

In this tutorial, we have shown you how to set up an Odoo 14 instance using Docker Compose. You can use this instance as a base to start building your Odoo applications.