Blog

How to Install Odoo 20 in Docker: Step-by-Step Guide

odoo20_docker
Odoo

How to Install Odoo 20 in Docker: Step-by-Step Guide

To install Odoo 20 in Docker, you need a reliable way to run Odoo and PostgreSQL without manually installing every dependency. Docker provides an isolated, repeatable environment that simplifies setup and reduces dependency conflicts across development, testing, and production systems.

In this guide, you will learn how to install Odoo 20 in Docker on Ubuntu using Docker Compose and PostgreSQL. At Banas Tech, we have over 9 years of experience implementing Odoo, and this guide follows a practical setup suitable for development and staging environments.

Why Install Odoo 20 in Docker?

Docker simplifies Odoo installation and management by running the application in isolated containers. It reduces dependency conflicts, makes configuration easier to maintain, and helps you deploy Odoo consistently across different systems. Docker Compose also lets you manage Odoo and PostgreSQL together using a single configuration file.

Benefits of using Docker:

  • Easy installation and configuration.
  • Isolated environment for Odoo and its dependencies.
  • Simplified application updates and maintenance.
  • Consistent setup across development and production environments.

To run Odoo using Docker, two containers are required. These containers can be created using the official Odoo and PostgreSQL images available on Docker Hub.

Step 1: Install Docker & Docker Compose
1.1 Add Docker’s official repository

sudo apt update
sudo apt install -y ca-certificates curl
sudo 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

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Now install Docker Engine and the Compose plugin:

sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

1.2 Check the service and verify the installation

First check that the Docker service is running:

sudo systemctl status docker

You should see active (running) in green. Press q to exit. Now check the versions and run a test container:

docker --version
docker compose version
docker run hello-world

If hello-world prints a welcome message, Docker is ready.

Step 2: Create the Project Folder

mkdir -p ~/odoo20-docker/config ~/odoo20-docker/addons
cd ~/odoo20-docker
  • config/ holds the Odoo configuration file.
  • addons/ is where your custom modules will go.

When all steps are done, your folder will look like this:

odoo20-docker/
├── .env
├── docker-compose.yml
├── config/
│   └── odoo.conf
└── addons/

Step 3: Create the Environment File

Keep passwords out of the compose file. Create a .env file:

cat > .env << 'EOF'
DB_PASSWORD=ChangeThisStrongPassword
EOF

Use a strong password of your own. Never commit this file to Git.

Step 4: Create the Odoo Configuration File

Create config/odoo.conf:

cat > config/odoo.conf << 'EOF'
[options]
admin_passwd = ChangeThisMasterPassword
addons_path = /mnt/extra-addons
data_dir = /var/lib/odoo
http_interface = 0.0.0.0
EOF

admin_passwd is the master password. You need it to create, back up and delete databases from the browser, so choose something strong and keep it safe. Database host, user and password are not written here on purpose: Docker Compose passes them to Odoo from the .env file (Step 5). That gives you one place to change the password and no chance of a mismatch.

Step 5: Create the docker-compose.yml File

cat > docker-compose.yml << 'EOF'
services:
  db:
    image: postgres:16
    container_name: odoo20-db
    restart: unless-stopped
    environment:
      POSTGRES_DB: postgres
      POSTGRES_USER: odoo
      POSTGRES_PASSWORD: ${DB_PASSWORD}
    volumes:
      - odoo-db-data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U odoo -d postgres"]
      interval: 10s
      timeout: 5s
      retries: 5

  odoo:
    image: odoo:20.0
    container_name: odoo20-web
    restart: unless-stopped
    depends_on:
      db:
        condition: service_healthy
    ports:
      - "8069:8069"
    environment:
      HOST: db
      USER: odoo
      PASSWORD: ${DB_PASSWORD}
    volumes:
      - odoo-web-data:/var/lib/odoo
      - ./config:/etc/odoo
      - ./addons:/mnt/extra-addons

volumes:
  odoo-db-data:
  odoo-web-data:
EOF

Here is what each part does:

  • db runs PostgreSQL 16 with a health check, so Odoo starts only when the database is ready.
  • odoo runs the official odoo:20.0 image and exposes port 8069.
  • odoo-db-data stores your database files, so data survives container restarts.
  • odoo-web-data stores Odoo filestore data such as attachments and sessions.
  • ./addons is mapped to /mnt/extra-addons for your custom modules.

Important: the official Odoo image reads HOST, USER and PASSWORD and uses them as database settings. HOST: db must match the database service name (db) in the same file.

Step 6: Start Odoo 20

docker compose up -d

The first run downloads the images, so it may take a few minutes. Check that both containers are running:

docker compose ps

You should see two containers: odoo20-db with status Up ... (healthy) and odoo20-web with status Up. If odoo20-web shows Restarting or Exited, go to the Troubleshooting section below.

Watch the Odoo logs:

docker compose logs -f odoo

When you see a line saying the HTTP service is running on port 8069, Odoo is ready. Press Ctrl + C to leave the log view (the containers keep running).


Now,Open your browser and go to http://localhost:8069 (or http://YOUR_SERVER_IP:8069 on a server).

Useful Docker Commands for Odoo
TaskCommand
Stop containersdocker compose stop
Start containersdocker compose start
Restart Odoo onlydocker compose restart odoo
View logsdocker compose logs -f odoo
Open a shell in Odoodocker compose exec odoo bash
Remove containers (data is kept)docker compose down
Remove containers and all datadocker compose down -v
Update modules from the command linedocker compose exec odoo odoo -d YOUR_DB -u module_name --stop-after-init

Conclusion

You now have Odoo 20 running in Docker with PostgreSQL 16, persistent data, and a folder for custom modules. The same setup is easy to copy to a new server, which makes it a great base for development, testing and staging.

Need help with a production deployment, performance tuning or moving to a newer version? The Banas Tech team offers Odoo Hosting, Odoo Migration and Odoo Development services. You can also hire an Odoo developer or contact us for a free discussion about your project.

Leave your thought here

Your email address will not be published. Required fields are marked *