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.
Furthermore, 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 are 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. We 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 the project:
- Keep your custom-addons/extra-addons inside this directory.
- Create a YML file for docker-compose (say docker_compose.yml)
Write instructions into the 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 - data:/var/lib/odoo depends_on: - db volumes: pg-odoo: data:
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 runs 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 the 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, the first DB service is running, then the 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
Furthermore, after accessing localhost on a certain port, get the above form to configure the database. We fill in this form with things 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.