Installing Odoo using Docker on Linux

Install Odoo using Docker Compose Linux ubuntu debian centos rRHEL

Odoo is a powerful open-source suite of business applications that covers a wide range of functionalities, including Customer Relationship Management (CRM), Website Builder, eCommerce, Project Management, Accounting, and more. And While you can install Odoo directly on your Linux system, using Docker to set up Odoo provides several advantages, such as easier deployment, better resource isolation, and consistent environments across different systems.

In this article, we’ll walk you through the step-by-step process of installing Odoo using Docker on a Linux system. We’ll cover the following topics:

  1. Prerequisites
  2. Installing Docker
  3. Pulling the Odoo Docker Image
  4. Creating a Docker Network
  5. Creating a PostgreSQL Container
  6. Creating an Odoo Container
  7. Accessing the Odoo Instance
  8. Configuring Odoo
  9. Updating Odoo
  10. Using Docker Compose for Odoo Installation

1. Prerequisites

Before we begin, make sure you have the following prerequisites in place:

  • A Linux system (this guide will use Ubuntu 20.04 LTS as an example, but the steps should be similar for other Linux distributions)
  • A non-root user with sudo privileges
  • A basic understanding of Docker and Linux command line

2. Installing Docker

Docker is a popular containerization platform that allows you to package applications and their dependencies into isolated containers. If you haven’t installed Docker on your Linux system yet, follow these steps:

  1. Update the package index:
$ sudo apt-get update
  1. Install the required packages to allow apt to use a repository over HTTPS:
$ sudo apt-get install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
  1. Add Docker’s official GPG key:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  1. Add the Docker repository to your system’s sources list:
$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
  1. Update the package index again:
$ sudo apt-get update
  1. Install the latest version of Docker Engine and containerd:
$ sudo apt-get install -y docker-ce docker-ce-cli containerd.io
  1. Verify that Docker is installed correctly by running the following command:
$ sudo docker run hello-world

If everything is set up correctly, you should see a message indicating that the Docker installation is successful.

3. Pulling the Odoo Docker Image

Odoo provides official Docker images that you can use to run Odoo in a containerized environment. To pull the latest Odoo image, run the following command:

$ sudo docker pull odoo:latest

This command will download the latest version of the Odoo Docker image from the official Docker Hub repository. If you prefer to use a specific version of Odoo, you can replace latest with the desired version tag (e.g., odoo:14.0).

4. Creating a Docker Network

Docker networks allow containers to communicate with each other. We’ll create a new network for our Odoo and PostgreSQL containers:

$ sudo docker network create odoo-network

This command creates a new Docker network named odoo-network.

5. Creating a PostgreSQL Container

Odoo requires a PostgreSQL database to store its data. We’ll create a PostgreSQL container and connect it to the odoo-network we just created:

$ sudo docker run -d -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo -e POSTGRES_DB=odoo --network=odoo-network --name db postgres:13

Let’s break down this command:

  • docker run: Runs a new container from an image
  • -d: Runs the container in detached mode (in the background)
  • -e POSTGRES_USER=odoo: Sets the PostgreSQL user to odoo
  • -e POSTGRES_PASSWORD=odoo: Sets the PostgreSQL password to odoo
  • -e POSTGRES_DB=odoo: Sets the name of the initial database to odoo
  • --network=odoo-network: Connects the container to the odoo-network
  • --name db: Assigns the name db to the container
  • postgres:13: Uses the official PostgreSQL 13 Docker image

This command creates a new PostgreSQL container named db connected to the odoo-network with a database named odoo and credentials odoo/odoo.

6. Creating an Odoo Container

Now that we have a PostgreSQL container up and running, we can create an Odoo container and link it to the PostgreSQL container:

$ sudo docker run -p 8069:8069 --name odoo --network=odoo-network -e HOST=db -e USER=odoo -e PASSWORD=odoo --link db:db -t odoo

Let’s break down this command:

  • docker run: Runs a new container from an image
  • -p 8069:8069: Maps the host’s port 8069 to the container’s port 8069 (Odoo’s default port)
  • --name odoo: Assigns the name odoo to the container
  • --network=odoo-network: Connects the container to the odoo-network
  • -e HOST=db: Sets the PostgreSQL host to db (the name of our PostgreSQL container)
  • -e USER=odoo: Sets the PostgreSQL user to odoo
  • -e PASSWORD=odoo: Sets the PostgreSQL password to odoo
  • --link db:db: Links the db container to the odoo container with an alias db
  • -t odoo: Specifies the Odoo Docker image to use

This command creates a new Odoo container named odoo connected to the odoo-network and linked to the PostgreSQL container db. It also maps the host’s port 8069 to the container’s port 8069, allowing you to access the Odoo instance from your web browser.

7. Accessing the Odoo Instance

Once the Odoo container is up and running, you can access the Odoo instance by opening a web browser and navigating to http://your_server_ip:8069. Replace your_server_ip with the IP address of your Linux server.

If everything is set up correctly, you should see the Odoo welcome screen. From here, you can create a new database or use the existing odoo database we created earlier.

8. Configuring Odoo

While the default configuration is suitable for most use cases, you may want to customize certain aspects of your Odoo installation. Odoo provides a configuration file called odoo.conf that allows you to modify various settings.

To access the odoo.conf file, you’ll need to create a new volume and mount it to the Odoo container. Here’s how you can do it:

  1. Create a new directory to store your Odoo configuration files:
$ sudo mkdir -p /opt/odoo/config
  1. Create a new odoo.conf file in the /opt/odoo/config directory:
$ sudo nano /opt/odoo/config/odoo.conf
  1. Add your desired configuration options to the odoo.conf file. For example, to change the default language and timezone:
[options]
; This is the password that allows database operations:
admin_passwd = my_admin_password
db_host = db
db_port = 5432
db_user = odoo
db_password = odoo
addons_path = /mnt/extra-addons
; Language
default_lang = fr_FR
; Timezone
timezone = Europe/Paris
  1. Save and close the odoo.conf file.
  2. Stop the existing Odoo container:
$ sudo docker stop odoo
  1. Remove the existing Odoo container:
$ sudo docker rm odoo
  1. Run a new Odoo container with the configuration volume mounted:
$ sudo docker run -p 8069:8069 --name odoo --network=odoo-network -e HOST=db -e USER=odoo -e PASSWORD=odoo --link db:db -v /opt/odoo/config:/etc/odoo -t odoo

In this command, we’ve added the -v /opt/odoo/config:/etc/odoo option to mount the /opt/odoo/config directory from the host to the /etc/odoo directory inside the container. This will allow Odoo to read the odoo.conf file from the mounted volume.

After running this command, your Odoo instance should now be configured with the settings specified in the odoo.conf file.

9. Updating Odoo

When a new version of Odoo is released, you’ll need to update your Docker image and containers to take advantage of the latest features and security updates. Here’s how you can update your Odoo installation:

  1. Pull the latest Odoo Docker image:
$ sudo docker pull odoo:latest
  1. Stop the existing Odoo container:
$ sudo docker stop odoo
  1. Remove the existing Odoo container:
$ sudo docker rm odoo
  1. Run a new Odoo container with the updated image:
$ sudo docker run -p 8069:8069 --name odoo --network=odoo-network -e HOST=db -e USER=odoo -e PASSWORD=odoo --link db:db -v /opt/odoo/config:/etc/odoo -t odoo:latest

This command is similar to the one we used to create the initial Odoo container, but with the latest tag at the end to specify that we want to use the latest version of the Odoo Docker image.

After running this command, your Odoo instance should be updated to the latest version.

10. Using Docker Compose for Odoo Installation

While you can run the Docker commands manually to set up Odoo and its dependencies, using Docker Compose can simplify the process by defining and managing multi-container Docker applications. Docker Compose allows you to specify the configuration for all the required containers in a single YAML file, making it easier to deploy and manage your Odoo setup.

Here’s how you can use Docker Compose to install Odoo:

Install Docker Compose

  1. Install Docker Compose if you haven’t already:
$ sudo apt-get install docker-compose
  1. Create a new directory for your Odoo project and navigate to it:
$ mkdir odoo-project
$ cd odoo-project
  1. Create a new file named docker-compose.yml in the odoo-project directory:
$ nano docker-compose.yml
  1. Add the following content to the docker-compose.yml file:
version: '3'
services:
  web:
    image: odoo:latest
    depends_on:
      - db
    ports:
      - "8069:8069"
    volumes:
      - ./config:/etc/odoo
    environment:
      - HOST=db
      - USER=odoo
      - PASSWORD=odoo
  db:
    image: postgres:13
    environment:
      - POSTGRES_USER=odoo
      - POSTGRES_PASSWORD=odoo
      - POSTGRES_DB=odoo
    volumes:
      - odoo-db-data:/var/lib/postgresql/data
volumes:
  odoo-db-data:

This docker-compose.yml file defines two services: web and db. The web service is the Odoo application, and the db service is the PostgreSQL database.

The web service specifies the following:

  • image: Uses the latest Odoo Docker image
  • depends_on: Specifies that the web service depends on the db service
  • ports: Maps the host’s port 8069 to the container’s port 8069
  • volumes: Mounts the ./config directory from the host to the /etc/odoo directory inside the container
  • environment: Sets environment variables for the Odoo container, including the database host, user, and password

The db service specifies the following:

  • image: Uses the PostgreSQL 13 Docker image
  • environment: Sets environment variables for the PostgreSQL container, including the database user, password, and name
  • volumes: Mounts a named volume odoo-db-data to persist the PostgreSQL data
  1. Save and close the docker-compose.yml file.
  2. Create the config directory to store your Odoo configuration files:
$ mkdir config
  1. Create a new odoo.conf file in the config directory and add your desired configuration options (refer to the “Configuring Odoo” section in the main article for more details).
  2. Start the Odoo and PostgreSQL containers using Docker Compose:
$ docker-compose up -d

This command will create and start the containers defined in the docker-compose.yml file. The -d flag runs the containers in detached mode (in the background).

  1. Access the Odoo instance by opening a web browser and navigating to http://your_server_ip:8069.

Using Docker Compose simplifies the process of setting up and managing multiple containers for your Odoo installation. The docker-compose.yml file serves as a single source of truth for your application’s configuration, making it easier to maintain and deploy your Odoo setup across different environments.

If you need to stop or remove the containers, you can use the following Docker Compose commands:

# Stop the containers
$ docker-compose stop
# Remove the containers
$ docker-compose down

Docker Compose provides a more structured and scalable approach to deploying and managing Odoo and its dependencies using Docker containers.

Troubleshooting

If you encounter any issues during the installation or configuration process, here are some common troubleshooting tips:

Checking Container Logs

If your Odoo instance isn’t working as expected, you can check the container logs for more information. To view the logs for the Odoo container, run:

$ sudo docker logs odoo

This command will display the logs for the odoo container, which can help you identify and diagnose any issues.

Checking Container Status

You can check the status of your Docker containers by running:

$ sudo docker ps -a

This command will list all the containers on your system, along with their status (running, exited, etc.). If a container is not running, you can try starting it with the following command:

$ sudo docker start container_name

Replace container_name with the name of the container you want to start (e.g., odoo or db).

Rebuilding Containers

If you’ve made changes to your Odoo configuration or encountered issues with your existing containers, you may need to rebuild them. Follow these steps to rebuild your Odoo and PostgreSQL containers:

  1. Stop the existing containers:
$ sudo docker stop odoo db
  1. Remove the existing containers:
$ sudo docker rm odoo db
  1. Remove the existing Docker network:
$ sudo docker network rm odoo-network
  1. Create a new Docker network:
$ sudo docker network create odoo-network
  1. Create a new PostgreSQL container:
$ sudo docker run -d -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo -e POSTGRES_DB=odoo --network=odoo-network --name db postgres:13
  1. Create a new Odoo container:
$ sudo docker run -p 8069:8069 --name odoo --network=odoo-network -e HOST=db -e USER=odoo -e PASSWORD=odoo --link db:db -v /opt/odoo/config:/etc/odoo -t odoo:latest

This process will create new containers with the latest configuration and any changes you’ve made.

Conclusion

After following this guide, you should now be able to successfully install and configure Odoo using Docker on your Linux system. Docker provides a convenient way to manage and deploy Odoo, ensuring consistent environments across different systems and simplifying the installation process.

Remember to consult the official Odoo documentation and community forums if you encounter any issues or have specific questions about configuring or customizing your Odoo installation.

LEAVE A COMMENT