Deploying Odoo 14 Using Docker

Perigeon Software
4 min readJan 25, 2021

--

Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code quickly, you can significantly reduce the delay between writing code and running it in production. Docker behaves like a virtual machine. By using Odoo Docker features, the user does not need to worry about dependencies, packages, and many more aspects.

To deploy Odoo on Docker, we needed to set-up two docker containers.

  1. Postgres Image : Odoo stores and manipulates its data using PostgreSQL. So before configuring the Odoo image we need to ensure that the postgres image is running perfectly without any errors.
  2. Odoo Image : There is an official image of the Odoo in the Docker hub which can be installed into the Docker Container [https://hub.docker.com/_/odoo]

Docker-Compose: Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.

let’s create a file that includes Odoo and PostgreSQL containers and we can start both the containers as a service as there is no necessity to start them individually.

Installing Docker-Compose:

Execute below command to download the compose file to /usr/local/bin directory:

sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Set executable permissions for the file using the following command:

sudo chmod +x /usr/local/bin/docker-compose

Check Docker version:

docker-compose — version

Deploying Odoo 14 using Docker-Compose:

Create a new directory for the project environment.

mkdir -p ~/docker/odoo14

cd ~/docker/odoo14

touch docker-compose.yml

mkdir ./config && touch config/odoo.conf

mkdir ./addons

mkdir ./enterprise #For adding the enterprise addons

mkdir ./data

mkdir ./data/odoo

mkdir ./data/postgres # To hold the odoo and postgres data

Adding the contents into ./docker-compose.yml:

Sample File , Run below command

nano docker-compose.yml

version: '1.0'
services:
# Information needed set up an odoo web
# application container.
web:
image: odoo:14.0
container_name: odoo_14
depends_on:
- db
# Port Mapping
#We are going to map the host machine(left side) with the
#Port inside the container (the right).
#Default Odoo Runs on port 8069 and inside the container, it is running on 8069.
#Locally we are going to access it via localhost:9000
ports:
- 9090:8069
# Data Volumes
# --------
# This defines files that we are sharing from the host machine
# into the container.
#
#Here we are using to map the extra add ons or enterprise addons
# as well as the configuration file. Also, we need to map the data
#directory where Odoo will storesome attachments etc.
volumes:
- ./data/odoo:/var/lib/odoo
- ./config:/etc/odoo
- ./addons:/intforce/extra
- ./enterprise:/intforce/enterprise
#Username and password of the Host DB
# Make sure to give the same credentials inside the postgres service
environment:
- HOST=db #[Hostname]
- USER=odoo14
- PASSWORD=odoo14

# All of the information needed to start up a Postgresql
# container.
db:
image: postgres:10
container_name: postgres_10
ports:
-5432:5432
#Add this volume to map the Postgres data. It may be lost
#if we execute docker-compose down where all the data
#in the layered file system will be lost
volumes:
- ./data/postgres:/var/lib/postgresql/data
#make sure to use the same which were given above.
environment:
- POSTGRES_PASSWORD=odoo14
- POSTGRES_USER=odoo14
- POSTGRES_DB=postgres

Odoo sample Config file needed to add inside ./config/odoo.conf to map the volume inside the container.

[options]

admin_passwd = admin_password
db_host = db
db_user = odoo14
db_password = odoo14
db_port = 5432
addons_path = /intforce/extra , /intforce/enterprise
proxy_mode = True
data_dir = /var/lib/odoo

Run :

docker-compose up

You can see the log from both the postgres as well as odoo. Once it is running we can access it from http://localhost:9090.

Extra Intformation- Docker Compose Commands

docker-compose up -d — Starts the containers in the background.

docker-compose restart — Restarts all the services.

docker-compose down — Destroys containers

docker-compose stop — Stops all the service

To Install additional packages inside docker container

docker exec -it <container name> /bin/bash to get a bash shell in the container

docker exec -it <container name> <command> to execute the command that specified

Perigeon Software is a software development firm. With a fresh perspective and dedicated attention to each client, we provide a complete IT solution globally. By defining, designing, and developing solutions tailored to meet our clients’ business objectives, we ensure that our clients get the maximum return on their investment and support them in tackling evolving business and technological issues. Our mission is to provide the best customer service and expertise using the most practical and robust web technologies/software technologies to satisfy our clients’ IT objectives and to provide them with the business and competitive advantage they needed to succeed.

To learn more about perigeon’s portfolio, visit: http://perigeon.com/portfolio/ or drop us a mail on possibilities@perigeon.com .

Originally published at https://www.perigeon.com

--

--

Perigeon Software
Perigeon Software

Written by Perigeon Software

We deliver customized global IT solutions using cutting-edge technology with expertise in Salesforce, Shopify, BigCommerce Data and AI.