Odoo is a comprehensive suite of business applications that streamlines operations ranging from sales and inventory management to accounting and human resources. Running Odoo in Docker containers simplifies deployment, ensures isolation, and improves scalability.
In this guide you install Odoo using Docker on Ubuntu, set up a dedicated PostgreSQL container for its database, and configure your system for persistent data storage. For those deploying production workloads, UpCloud provides high-performance cloud servers with robust networking and scalable storage, ensuring your Odoo instance runs reliably and efficiently.
Prerequisites
Ensure your Ubuntu server is properly set up with a non-root user who has sudo privileges and that Docker is installed on your system. Verify your firewall settings and update your system to the latest security patches. You also need to have an account on Docker Hub to pull the official Docker images for Odoo and PostgreSQL.
Before you begin, make sure you have the following:
Basic Linux Command-Line Skills:
You will work with commands such as apt
, nano
, and openssl
to configure your system.
Docker Installed:
Ensure that both Docker is installed and running on your server. (See guide: How to install and use Docker on Ubuntu)
A Domain or IP Address:
You need a domain (for example, odoo.example.com
) or an IP address that points to your server. This guide uses the domain in the Nginx configuration.
Step 1 — Installing Docker Compose
Start by updating your package list and installing the docker-compose tool using apt:
sudo apt update
sudo apt install docker-compose
If you prefer to install a more recent version of Docker Compose, follow the instructions in the guide for Ubuntu 22.04/20.04/18.04. In that case, use the command docker compose
(without the hyphen) instead of docker-compose
.
Confirm the installation by running:
docker-compose --version
You should see output similar to:
docker-compose version 1.25.0, build unknown
docker-py version: 4.1.0
CPython version: 3.8.10
Once you have confirmed that Docker Compose is installed, you can move on to configuring your Odoo and PostgreSQL containers.
Step 2 — Running Odoo and PostgreSQL with Docker Compose
Begin by creating a directory to hold all the files required to run Odoo. This directory will store your configuration files and persistent data.
Run the following commands to create the directory and change into it:
mkdir ~/odoo
cd ~/odoo
Next, create a new YAML file named docker-compose.yml
using your preferred text editor (here, nano is used):
nano docker-compose.yml
Paste the following content into the file. This configuration defines two services—one for Odoo and one for PostgreSQL—and links them together while mapping named volumes for data persistence:
version: '3'
services:
odoo:
image: odoo:15.0
env_file: .env
depends_on:
- postgres
ports:
- "127.0.0.1:8069:8069"
volumes:
- data:/var/lib/odoo
postgres:
image: postgres:13
env_file: .env
volumes:
- db:/var/lib/postgresql/data/pgdata
volumes:
data:
db:
Save and exit the file (in nano, press CTRL+O then RETURN to save, and CTRL+X to exit).
Both services reference an environment file for sensitive variables. To create that file, open a new file named .env
:
nano .env
Add the following lines to the file. Replace the placeholder values with a secure username and password of your choice:
# PostgreSQL environment variables
POSTGRES_DB=postgres
POSTGRES_PASSWORD=a_strong_password_for_user
POSTGRES_USER=odoo
PGDATA=/var/lib/postgresql/data/pgdata
# Odoo environment variables
HOST=postgres
USER=odoo
PASSWORD=a_strong_password_for_user
If you need a strong password, generate one with the following command:
openssl rand -base64 30
Paste the generated string into the .env
file in place of a_strong_password_for_user
.
Save and exit the file. Now you are ready to start your containers.
Run the following command to deploy your Odoo and PostgreSQL containers in detached mode:
docker-compose up -d
Docker Compose will create the required networks, volumes, and containers. You will see output similar to:
Creating network "odoo_default" with the default driver
Creating volume "odoo_odoo_data" with default driver
Creating volume "odoo_postgres_data" with default driver
Pulling odoo (odoo:14.0)...
15.0: Pulling from library/odoo
. . .
To stop the containers later while preserving your data, run:
docker-compose stop
Test that Odoo is running by fetching the homepage headers:
curl --head http://localhost:8069
A response header like the following indicates that Odoo is up and running:
HTTP/1.0 303 SEE OTHER
Content-Type: text/html; charset=utf-8
Content-Length: 215
Location: http://localhost:8069/web
Set-Cookie: session_id=142fa5c02742d0f5f16c73bc14ec8144b8230f8a; Expires=Mon, 06-Jun-2022 20:45:34 GMT; Max-Age=7776000; HttpOnly; Path=/
Server: Werkzeug/0.14.1 Python/3.7.3
Date: Tue, 08 Mar 2022 20:45:34 GMT
Step 3 — Installing and Configuring Nginx
To improve performance and enable TLS later, install Nginx as a reverse proxy for Odoo.
Refresh your package list and install Nginx:
sudo apt update
sudo apt install nginx
Allow public traffic on ports 80 and 443 by running:
sudo ufw allow "Nginx Full"
Next, create a new Nginx configuration file. Open a file called odoo.conf
in the /etc/nginx/sites-available
directory:
sudo nano /etc/nginx/sites-available/odoo.conf
Paste the following configuration into the file. Replace your_domain_here
with your actual domain (for example, odoo.example.com
):
server {
listen 80;
listen [::]:80;
server_name your_domain_here;
access_log /var/log/nginx/odoo.access.log;
error_log /var/log/nginx/odoo.error.log;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_pass http://localhost:8069;
}
}
Save and close the file. Enable this configuration by linking it to the sites-enabled
directory:
sudo ln -s /etc/nginx/sites-available/odoo.conf /etc/nginx/sites-enabled/
Test the configuration syntax:
sudo nginx -t
You should see:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Reload Nginx to apply the new settings:
sudo systemctl reload nginx.service
Your Odoo instance is now accessible via HTTP through your domain.
Step 4 — Installing Certbot and Setting Up TLS Certificates
To secure your Odoo installation, install Certbot and the Nginx plugin:
sudo apt install certbot python3-certbot-nginx
Run Certbot in Nginx mode and specify your domain:
sudo certbot --nginx -d your_domain_here
Follow the prompts to agree to the terms of service and enter your email address. When asked, choose to redirect all HTTP traffic to HTTPS. Certbot will automatically obtain your certificate, configure Nginx, and reload the service.
You should see output confirming that HTTPS has been enabled. You can test your secure configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=your_domain_here
Step 5 — Setting Up Odoo
Now that your containers are running and your site is secured, open your web browser and visit your Odoo site using HTTPS (for example, https://odoo.example.com
).
You will see the Odoo database setup page. On this page, provide the following details:
- Database Name: odoo
- Email: Enter your email address
- Password: Choose a strong, unique password for your administrator account
- Demo Data: Check this option if this is your first installation
After filling in the details, click the Create Database button. It may take a few minutes for Odoo to create its database tables. When complete, you will be redirected to the Odoo Apps dashboard, where you can start enabling the modules that suit your ERP needs.
Conclusion
You have now successfully deployed Odoo and PostgreSQL using Docker Compose, set up an Nginx reverse proxy, and secured your installation with Let’s Encrypt TLS certificates. You are ready to customize your Odoo installation and start building your ERP website.
For more information on customizing or developing your own Odoo modules, consult the official Odoo documentation and developer guides.
Happy hosting!
Leave a Reply