Step-by-step instructions to install Odoo on Ubuntu 24.04 using Docker and Docker Compose. This method is highly recommended as it isolates your Odoo instance and its dependencies in containers, making it clean and easy to manage.

Prerequisites: Install Docker & Docker Compose

First, you need to ensure Docker and Docker Compose are installed on your Ubuntu 24.04 system.

  1. Update your package
Bashsudo apt update
  1. Install Docker and Docker Compose: In Ubuntu 24.04, you can install both from the standard repositories.Bash sudo apt install docker.io docker-compose-v2 -y
  2. Add your user to the Docker group (to run Docker commands without sudo):Bashsudo usermod -aG docker ${USER} ⚠️ Important: You must log out and log back in for this change to take effect.

Step 1: Create a Project Directory

It’s best practice to keep all your configuration files in a dedicated folder.

  1. Create a directory for your Odoo project:Bashmkdir ~/odoo-docker
  2. Navigate into your new directory:Bashcd ~/odoo-docker

Step 2: Create the docker-compose.yml File

This file defines the services, networks, and volumes for your Odoo application. It will orchestrate the Odoo container and its PostgreSQL database container.

Create the file using a text editor like nano:

Bash

nano docker-compose.yml

Paste the following configuration into the file. This setup uses Odoo 17 and PostgreSQL 15.

YAML

version: '3.8'

services:
  db:
    image: postgres:15
    container_name: odoo_db
    environment:
      - POSTGRES_USER=odoo
      - POSTGRES_PASSWORD=my_strong_password
      - POSTGRES_DB=postgres
    restart: always
    volumes:
      - db_data:/var/lib/postgresql/data
    networks:
      - odoo_network

  odoo:
    image: odoo:17.0
    container_name: odoo_app
    depends_on:
      - db
    ports:
      - "8069:8069"
    environment:
      - HOST=db
      - USER=odoo
      - PASSWORD=my_strong_password
    volumes:
      - odoo_data:/var/lib/odoo
      - ./addons:/mnt/extra-addons
    restart: always
    networks:
      - odoo_network

volumes:
  db_data:
  odoo_data:

networks:
  odoo_network:
    driver: bridge
Key points in this file:
  • services: We define two services: db (the PostgreSQL database) and odoo (the application itself).
  • image: Specifies which Docker images to use (e.g., postgres:15, odoo:17.0).
  • environment: Sets environment variables. The POSTGRES_PASSWORD in the db service must match the PASSWORD in the odoo service.
  • volumes: db_data and odoo_data are created to persist your data even if you remove the containers. The ./addons folder is mapped to store your custom Odoo modules.
  • ports: Maps port 8069 of the Odoo container to port 8069 on your host machine.

Save the file and exit nano by pressing CTRL + X, then Y, and Enter.


Step 3: Create the Custom Addons Directory

As defined in the docker-compose.yml file, you need a local directory to hold any custom addons you might want to install.

Create the addons folder inside your ~/odoo-docker directory:

Bash

mkdir addons

Step 4: Launch the Odoo Instance 🚀

Now you’re ready to start your Odoo and database containers.

Run the following command from your ~/odoo-docker directory:

Bash

docker-compose up -d
  • The up command creates and starts the containers.
  • The -d flag runs the containers in “detached” mode, meaning they run in the background.

Docker will now pull the Odoo and PostgreSQL images (which may take a few minutes the first time) and then create and start the containers. You can check the status with:

Bash
docker-compose ps

You should see both the odoo_app and odoo_db containers with a status of running or up.


Step 5: Access and Configure Odoo

Your Odoo instance is now running!

  1. Open your web browser and navigate to: http://localhost:8069
  2. You will be greeted by the Odoo setup screen to create your first database.
  3. Master Password: Odoo automatically generates a master password for managing databases. You can find it in the Odoo container’s logs. To view it, run:Bashdocker-compose logs odoo | grep "master password" Copy this password and save it in a secure location.
  4. Fill out the form:
    • Master Password: Paste the password you just retrieved.
    • Database Name: Give your database a name (e.g., my-company).
    • Email / Password: This will be the admin login for your Odoo instance.
    • Country: Select your country.
    • Demo data: Check this box if you want to populate your instance with sample data to explore Odoo’s features.
  5. Click Create database. After a moment, you will be redirected to the Odoo apps dashboard, ready to use! 🎉

Managing Your Odoo Instance

Here are some useful commands to manage your Dockerized Odoo setup. Run these from your ~/odoo-docker directory.

  • To stop the containers:
  • Bash
  • docker-compose stop
  • To start the containers again:Bashdocker-compose start
  • To view live logs (useful for debugging):Bashdocker-compose logs -f odoo (Press CTRL + C to stop viewing the logs).
  • To stop and remove the containers completely (your data in the db_data and odoo_data volumes will be preserved):Bashdocker-compose down

At step 2 i have the following error – The following packages have unmet dependencies:

containerd.io : Conflicts: containerd
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

 That error, containerd.io : Conflicts: containerd, means that your system is trying to install Docker’s version of a component (containerd.io) while another version (containerd), likely from Ubuntu’s default repositories, is already present or selected for installation, and they can’t coexist.

Here are two solutions to fix this. The second one is the most recommended for long-term stability.


Solution 1: Clean Up Existing Packages and Retry

This approach removes any potentially conflicting packages before you try the installation again.

  1. Remove any old or conflicting versions of Docker and containerd:Bashsudo apt-get remove docker docker-engine docker.io containerd runc It’s okay if this command says some packages were not found.
  2. Update your package list again:Bashsudo apt-get update
  3. Now, re-run the original installation command:Bashsudo apt-get install docker.io docker-compose-v2 -y

This usually resolves the conflict by ensuring a clean slate before installation.


Solution 2 (Recommended): Use Docker’s Official Repository

This is the method recommended by Docker itself. It ensures you get the latest versions directly from the source and avoids conflicts with Ubuntu’s own packages.

  1. Uninstall any old versions (same as step 1 above):Bashsudo apt-get remove docker docker-engine docker.io containerd runc
  2. Set up Docker’s repository:
    • First, install the necessary prerequisite packages:Bashsudo apt-get update sudo apt-get install ca-certificates curl
    • Add Docker’s official GPG key to ensure the downloads are authentic:Bashsudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc
    • Add the Docker repository to your system’s software sources:Bashecho \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  3. Install Docker Engine and Compose ✅:
    • Update your package list one more time to include the new Docker packages:Bashsudo apt-get update
    • Install the latest versions from Docker’s official repository:Bashsudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
    This command installs the full suite, including the Docker Engine (docker-ce), command-line interface, containerd.io, and the Docker Compose plugin.

After successfully completing either solution, you can continue with the rest of the original instructions, starting with adding your user to the docker group:

Bash
sudo usermod -aG docker ${USER}

Remember to log out and log back in for this group change to take effect, and then proceed to create your odoo-docker directory.

At step 2 of the solution dencies:i have the following error – The following packages have unmet dependencies:

containerd.io : Conflicts: containerd

E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

This usually happens when the system’s package manager has conflicting information from different software sources.

Let’s resolve this by taking the most reliable approach: we will completely remove all conflicting packages and then install Docker using its official repository. This method is guaranteed to work as it provides all the correct dependencies.

Please follow these steps exactly.


Step 1: Perform a Full Cleanup

This step will thoroughly remove any existing Docker or containerd packages that could be causing the issue.

  1. Purge all related packages: The purge command is stronger than remove as it also deletes configuration files.Bashsudo apt-get purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker.io runc Don’t worry if it says some packages were not found; the goal is to ensure they are all gone.
  2. Remove unused dependencies: This cleans up any leftover libraries.Bashsudo apt-get autoremove -y

Step 2: Set Up Docker’s Official Repository

Now, we’ll tell your system to use Docker’s official software source.

  1. Update package list and install prerequisites:Bashsudo apt-get update sudo apt-get install ca-certificates curl
  2. Add Docker’s official GPG security key:Bashsudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc
  3. Add the Docker repository to your system’s sources:Bashecho \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Step 3: Install and Verify

With the cleanup and setup complete, the installation should now proceed without conflicts.

  1. Update the package list again (this is crucial to read from the new Docker repository):Bashsudo apt-get update
  2. Install the Docker packages:Bashsudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
  3. Verify the installation: Run the “hello-world” container to confirm Docker is working correctly.Bashsudo docker run hello-world If successful, you will see a message beginning with “Hello from Docker!”. This confirms your installation is working perfectly.

Once you see the “Hello from Docker!” message, you can continue with the original instructions, starting with adding your user to the docker group:

Bash

sudo usermod -aG docker ${USER}

Remember to log out and log back in, and then you can proceed with creating the odoo-docker directory and the docker-compose.yml file.