Everyone wants to install software easily and quickly. Consequently, nobody wants to get trapped in installing software due to dependency issues or others that may cause the installation process to fail. Similarly, there are numerous issues with Odoo installation.
Therefore we utilize Docker to deploy applications to address such issues. Further users can run Odoo instances in any environment without worrying about dependencies, setups, or other issues.
We’ll learn how to install Odoo using Docker Compose in this article.
Docker is an open-source platform as a service (PaaS) that allows you to build, deploy, and operate programs in separate containers. Therefore enables us to install and run software without having to worry about the machine’s configuration or dependencies.
Further a Docker Image is a file that contains instructions for building and operating containers on the Docker platform. To put it another way, it’s a snapshot of a file system.
Docker Hub is a cloud-based registry where we can store images. It is used to store and distribute images.
To deploy Odoo, we will be using the official Odoo and the Postgres Docker Image. Both are available on Docker Hub to use.
Postgres image: As we all know, Odoo uses Postgres as a database to store and manipulate data. Postgres images are available on Docker Hub.
Odoo Image: There is an official Odoo image available on the Docker hub that can be used to install and run Odoo.
Docker compose is a tool for defining and running multi-container docker applications. Meanwhile it manages our web application. YML files is used by it to configure application services. It can extend selected services as needed. All services can be started or stopped with a single command.
Further Docker Compose is already available in Docker Desktop on Windows. Therefore there is no need to install Compose separately for Windows users.
To deploy Odoo, we will use docker-editor. In Odoo it needs Odoo and Postgres, we create a docker compose file and include both Odoo and Postgres containers and can start and stop both containers with one command.
How to Use Docker-Compose to Run Odoo?
Firstly you need to create a directory for project:
- Keep your custom-addons / extra-addons inside this directory
- Create YML file for docker-compose (say docker_compose.yml)
Write instructions into Docker-compose file
version: “3.1” services: db: image: postgres:latest restart: always ports: - 5444:5432 environment: POSTGRES_USER: odoo POSTGRES_PASSWORD: odoo volumes: - pg-odoo: /var/lib/postgresql/data odoo: image: odoo:latest ports: - 8069:8069 environment: - HOST=db - PORT=5432 - USER=odoo - PASSWORD=odoo volumes: - ./extra-addons:/mnt/extra-addons depends_on: - db volumes: pg-odoo
This YML file includes two services. The first is db, which is used to run the PostgreSQL container on port 5444. The second is Odoo, which is used to run the Odoo container on port 8069.
Odoo and PostgreSQL containers use environment variables to configure themselves like POSTGRES_PASSWARD, HOST, USER, etc.
To add custom addons/extra-addons create a custom directory and include mount this custom directory as written in odoo service:
We create two volumes for both services to store container data and be able to retrieve this data at any time in the future. There is a depend_on in Odoo services that specifies that the odoo service depends on another service. In this first db service is running, then Odoo service.
Therefore after completing all the necessary steps, we run the docker compose command to run the YML file:
docker-compose -f <YML file name> up
Now, We can access it from http://localhost:8069
Further after accessing localhost on a certain port, get above form to configure the database. We fill this form like database name, master password for database email, password etc.
Install the application from the application list and launch Odoo according to your needs.
Configuring Odoo via Docker makes installing the Odoo instance very smooth and easy. You don’t have to worry about dependencies, libraries and configuration. We can easily run Odoo in any environment.