Tutorial

How To Install Odoo with Docker on Ubuntu

Published on February 28, 2024
How To Install Odoo with Docker on Ubuntu

Odoo is an open-source enterprise resource planning (ERP) tool written in Python. It supports a number of plugins for different kinds of business needs like accounting, payroll, inventory management, and more.

In this tutorial you will install Odoo and a PostgreSQL database using Docker Compose, then install Nginx to act as a reverse proxy for your Odoo site. Finally, you will enable secure HTTPS connections by using Certbot to download and configure a TLS certificate from the Let’s Encrypt Certificate Authority.

Prerequisites

If you are using Ubuntu version 16.04 or below, we recommend you upgrade to a more latest version since Ubuntu no longer provides support for these versions. This collection of guides will help you in upgrading your Ubuntu version.

To complete this tutorial, you will need:

  • An Ubuntu server with 2 or more CPUs, having a non-root user with sudo privileges and an active firewall. For guidance on how to set these up, please choose your distribution from this list and follow our Initial Server Setup Guide.

  • Docker installed. Follow Step 1 and Step 2 of “How To Install and Use Docker on Ubuntu” 22.04 / 20.04 / 18.04 to install it and configure your non-root user to be able to run docker commands.

Note: You can skip these prerequisites if you are using DigitalOcean’s One-Click Docker Image. This image is pre-configured with Docker, Docker Compose, and UFW.

Launch a new Docker image in the region of your choice, then log in as the root user and proceed with the tutorial.

  • Finally, to enable TLS you’ll need a domain name pointed at your server’s public IP address. This should be something like example.com or odoo.example.com. If you are using DigitalOcean, please see our DNS Quickstart for information on creating domain resources in your control panel.

Once you have all the prerequisites in place, proceed to Step 1, where you’ll install the docker-compose package.

Step 1 — Installing Docker Compose

To install the docker-compose command line tool, refresh your package list, then install the package using apt:

  1. sudo apt update
  2. sudo apt install docker-compose

Note: You can also install a more recent Docker Compose package than the one that is included with Ubuntu. To do so, follow Step 1 of How To Install and Use Docker Compose on Ubuntu 22.04 / 20.04 / 18.04.

If you opt to use this version of Docker Compose, you will need to substitute docker compose as the command in place of docker-compose.

You can confirm that the package is installed by running the following command:

  1. docker-compose –version

You should receive output like the following:

Output
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 on your server, you will configure and launch Odoo and PostgreSQL using Docker Compose in the next step of this tutorial.

Step 2 — Running Odoo and PostgreSQL with Docker Compose

To get started creating your Odoo and PostgreSQL containers, create a directory called odoo in your home directory to store the files that you will create in this tutorial. You’ll use this directory to store all the files that you need to run Odoo.

Run the following commands to create the directory and then cd into it:

  1. mkdir ~/odoo
  2. cd ~/odoo

Now open a new blank YAML file called docker-compose.yml using nano or your preferred editor:

  1. nano docker-compose.yml

You will use this file with the docker-compose command to start your Odoo and PostgreSQL containers and link them together. Add the following lines to the file:

docker-compose.yml
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:

The file defines two services. The first is called odoo, which runs the Odoo application. The second is called postgres, which is the PostgreSQL database container. Both services reference named volumes that they use to store data outside of the running container instances. Finally, the odoo service exposes port 8069 on your server to the Odoo container that is running on the same port 8069.

Save and exit the file when you are done editing it. If you are using nano, press CTRL+O then RETURN to save, then CTRL+X to exit.

The Odoo and PostgreSQL containers use environment variables to configure themselves. The docker-compose.yml file specifies the env_file directive for both services. That directive then includes the referenced file that contains the variables that each service needs to run.

This approach is generally recommended instead of adding environment variables to the docker-compose.yml file directly, since it is a good practice to keep passwords out of your docker-compose.yml file. This approach is especially applicable if you’ll be committing your files to a Git repository or another source control system.

Open a new .env file with nano:

  1. nano .env

Add the following lines into the file, substituting in a POSTGRES_USER and POSTGRES_PASSWORD of your choice in place of the highlighted values:

.env
# 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

To generate a password for Odoo and PostgreSQL, use the openssl command, which should be available on most Linux systems. Run the following command on your server to generate a random set of bytes and print a base64 encoded version that you can use as a password:

  1. openssl rand -base64 30

Paste the resulting string into your .env file in place of the a_strong_password_for_user placeholder passwords.

When you’re done editing your .env file, save and exit your text editor.

You’re now ready to start the odoo and postgres containers with the docker-compose command:

  1. docker-compose up -d

The up sub-command tells docker-compose to start the containers and the associated volumes and networks that are defined in the docker-compose.yml file. The -d flag (which stands for “daemonize”) tells docker-compose to run the containers in the background so the command doesn’t take over your terminal. docker-compose will print some brief output as it downloads the required Docker images and then starts the containers:

Output
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 . . .

If you would like to stop your Odoo and PostgreSQL containers at any time, run the following command in your ~/odoo directory:

  1. docker-compose stop

The containers will be stopped. The configuration and data in their volumes will be preserved so that you can start the containers again with the docker-compose up -d command.

When that’s done, Odoo should be running. You can test that a webserver is running at 127.0.0.1:8069 by fetching the homepage using the curl command:

  1. curl --head http://localhost:8069

This will print out only the HTTP headers from the response:

Output
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

The 303 SEE OTHER response means the Odoo server is up and running, but that you should visit another page to complete the installation. The highlighted http://localhost:8069/web Location header indicates where to visit the Odoo installer page in your browser.

Next we’ll set up Nginx to proxy public traffic to the Odoo container.

Step 3 — Installing and Configuring Nginx

Putting a web server such as Nginx in front of your Odoo server can improve performance by offloading caching, compression, and static file serving to a more efficient process. We’re going to install Nginx and configure it to reverse proxy requests to Odoo, meaning it will take care of handing requests from your users to Odoo and back again. Using a non-containerized Nginx process will also make it easier to add Let’s Encrypt TLS certificates in the next step.

First, refresh your package list, then install Nginx using apt:

  1. sudo apt update
  2. sudo apt install nginx

Allow public traffic to ports 80 and 443 (HTTP and HTTPS) using the Nginx Full UFW application profile:

  1. sudo ufw allow "Nginx Full"
Output
Rule added Rule added (v6)

Next, open up a new Nginx configuration file in the /etc/nginx/sites-available directory. We’ll call ours odoo.conf but you could use a different name:

  1. sudo nano /etc/nginx/sites-available/odoo.conf

Paste the following into the new configuration file, being sure to replace your_domain_here with the domain that you’ve configured to point to your Odoo server. This should be something like odoo.example.com, for instance:

/etc/nginx/sites-available/odoo.conf
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;
  }
}

This configuration is HTTP-only for now, as we’ll let Certbot take care of configuring TLS in the next step. The rest of the configuration file sets up logging locations and then passes all traffic, as well as some important proxy headers, along to http://localhost:8069, the Odoo container that we started up in the previous step.

Save and close the file, then enable the configuration by linking it into /etc/nginx/sites-enabled/:

  1. sudo ln -s /etc/nginx/sites-available/odoo.conf /etc/nginx/sites-enabled/

Use nginx -t to verify that the configuration file syntax is correct:

  1. sudo nginx -t
Output
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful

And finally, reload the nginx service with the new configuration:

  1. sudo systemctl reload nginx.service

Your Odoo site should now be available on plain HTTP. Load http://your_domain_here (you may have to click through a security warning) and it will look like this:

Screenshot of Odoo's "Database Setup" page, with a form for inputting database connection details and a random password for the PostgreSQL database

Now that you have your site up and running over HTTP, it’s time to secure the connection with Certbot and Let’s Encrypt certificates. You should do this before going through Odoo’s web-based setup procedure.

Step 4 — Installing Certbot and Setting Up TLS Certificates

Thanks to Certbot and the Let’s Encrypt free certificate authority, adding TLS encryption to your Odoo app will take only two commands.

First, install Certbot and its Nginx plugin:

  1. sudo apt install certbot python3-certbot-nginx

Next, run certbot in --nginx mode, and specify the same domain that you used in the Nginx server_name configuration directive:

  1. sudo certbot --nginx -d your_domain_here

You’ll be prompted to agree to the Let’s Encrypt terms of service, and to enter an email address.

Afterwards, you’ll be asked if you want to redirect all HTTP traffic to HTTPS. It’s up to you, but this is generally recommended and safe to do.

After that, Let’s Encrypt will confirm your request and Certbot will download your certificate:

Output
Congratulations! You have successfully enabled https://odoo.example.com You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=odoo.example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/odoo.example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/odoo.example.com/privkey.pem Your cert will expire on 2022-05-09. To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option. To non-interactively renew *all* of your certificates, run "certbot renew" - Your account credentials have been saved in your Certbot configuration directory at /etc/letsencrypt. You should make a secure backup of this folder now. This configuration directory will also contain certificates and private keys obtained by Certbot so making regular backups of this folder is ideal. - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le

Certbot will automatically reload Nginx with the new configuration and certificates. Reload your site in your browser and it should switch you over to HTTPS automatically if you chose the redirect option.

Your site is now secure and it’s safe to continue with the web-based setup steps.

Step 5 — Setting Up Odoo

Back in your web browser, reload the page. You should now have Odoo’s database configuration page open via a secure https:// connection. Now you can enter usernames and passwords safely to complete the installation process.

The information that you fill in on this page will tell the Odoo application how to create its PostgreSQL database and details about the default administrative user.

Fill out the following fields:

  • Database Name: odoo
  • Email: your email address
  • Password: a strong and unique password for your administrator login
  • Demo data: ensure that this option is checked if this is the first time that you are installing odoo

The defaults are fine for the remaining fields. Be sure to record the email and password values that you choose since you will use them to login to Odoo in the future.

Now click the Create database button at the bottom left of the page. It may take a minute or two for Odoo to create its database tables. When the process is complete you will be redirected to the Odoo Apps administrative page.

Screenshot of Odoo's Apps dashboard with a list of available modules that can be enabled

From here you can choose which Odoo modules you would like to install and use for your ERP needs. If you would like to test an app, click the Install button on the Sales tile. Odoo will install the module and then redirect you to your personal Discuss app page.

Click the segmented square icon at the top left of your screen and then select the Sales link in the list of dropdown options.

Screenshot of Odoo's Sales app dashboard with customization options

You will be on a page that will guide you through customizing data, quotes, orders, and a list of example sales that you can experiment with.

Conclusion

In this tutorial, you launched the Odoo ERP app and a PostgreSQL database using Docker Compose, then set up an Nginx reverse proxy and secured it using Let’s Encrypt TLS certificates.

You’re now ready to start building your ERP website using the supplied modules. For more information about using Odoo please see the official Odoo documentation.

If you would like to write your own custom Odoo modules or customize existing modules, the Developer documentation is a good place to start.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors

Default avatar

Technical Writer


Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
2 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Can you guys please make a guide on how we can install odoo custom Addons in this docker installation setup?

Hi, can you please tell us how to install Odoo 17.0 in this process?

I tried to install the 17.0, but it seems to be not working. I saw that you mentioned image: odoo:15.0 in the “docker-compose.yml” file. I change it to image: odoo:17.0 when installing. But After finishing the installation, the command curl --head http://localhost:8069 shows this error

curl: (7) Failed to connect to 127.0.0.1 port 8069 after 0 ms: Connection refused

And the web URL also does not work. http://ip-address:8069

FYI, I am using a digital ocean Droplates with Ubuntu 22.04 and Docker installed on it.

It would be very helpful if you could share the odoo 17 installation guide with SSL.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.