Enable Dark Mode!
how-to-deploy-odoo-15-using-docker.jpg
By: Mohd Shamsad PS

How to Deploy Odoo 15 Using Docker

Technical Odoo 15

With the help of containers, developers and users can create, distribute, run, and manage their apps using the Docker platform for application-level deployment. These containers give programmers the ability to create packages, tools, environments, libraries, etc., by combining various parts of their software into a single instance. This allows developers in any other environment to run their applications without worrying about the different types of dependencies they may have. Furthermore, Docker actually operates like a virtual machine. The user can avoid worrying about dependencies, packages, and many other issues by using Odoo Docker features.
When looking at the Odoo image, has all the necessary packages and libraries to make Odoo run smoothly. Initially, we had to set up two Docker containers in order to deploy Odoo on them.

Odoo Image:

The official image of Odoo is available in the docker hub for different versions.

Postgres Image:

Before configuring the Odoo, ensure that Postgres is running in the docker without any errors since Odoo stores and manipulates data using Postgres.

Installing Docker in Ubuntu 20.04

Docker Engine is compatible with x86_64(amd64), armfh, arm64 and s390x architectures. Before Installing the latest versions of Docker, uninstall older versions by the name of docker, docker.io, or docker-engine. If we want a clean installation, then clean up the existing data stored in /var/lib/docker.

sudo apt-get remove docker docker-engine docker.io containerd runc

Set up repository

First, update the apt package and Install the necessary packages to enable apt to access an HTTPS repository: 

sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release


Add Docker’s official GPG key
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

Run the below command to set up the repository

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Install Docker Engine

Run the following command to install the docker

sudo apt update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
To verify the installation is successful we can run the hello-world image
sudo docker run hello-world
It will give a message as shown below:
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/
For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Installing Odoo in Docker

Create a new directory for the setup

mkdir -p /docker/odoo
cd ~/docker/odoo
mkdir config
mkdir addons
mkdir config
mkdir extra-addons

After that, we are setting up the Postgres configuration. It is a good practice to create a separate file for passwords so that our docker-composer yml file does not contain the password of Postgres.

sudo nano .env
#psql environment variable
POSTGRES_DB=postgres
POSTGRES_PASSWORD=odoo
POSTGRES_USER=odoo15
PGDATA=/var/lib/postgresql/data/pgdata
#odoo environment variables
HOST=postgres
USER=odoo15
PASSWORD=odoo

After that press ctrl+o and press enter. Then press ctrl+x to exit.

Then we are going to create docker-compose file in which we use to link the Odoo and postgres

nano docker-compose.yml
version: '3'
services:
 odoo:
   image: odoo:15.0 #image of the odoo
   env_file: .env #environment file(contains odoo environment)
   depends_on:
     - postgres
   ports:
     - "8000:8069" #port mapping
   Volumes: #mapping directory
     - data:/var/lib/odoo
     - ./config:/etc/odoo 
     - ./extra-addons:/mnt/extra-addons
 postgres: 
   image: postgres:13 #postgres image
   env_file: .env #environment file(contains postgres environment)
   volumes:
     - db:/var/lib/postgresql/data/pgdata
volumes:
 data:
 db:
After that, press ctrl+o and press enter. Then press ctrl+x to exit.
Now we are going to create a odoo.conf file inside the directory config.
[options]
admin_passwd = admin_password
db_host = postgres
db_user = odoo15
db_password = odoo
db_port = 5432
addons_path = /mnt/extra-addons

To run we have to run the following command in terminal

docker-compose up 
It will show the log of both Postgres and Odoo.
Since we have mapped the port to 8000, to access the Odoo through 
http://localhost:8000
To install an additional package to the container:
Docker exec -it [container name] /bin/bash To get bash shell
Docker exec -it [container name] [command] To execute the command


If you need any assistance in odoo, we are online, please chat with us.



1
Comments

siva prakash

"Volumes" in not support use lowercase "volumes"

20/04/2023

-

5:40PM



Leave a comment

 


whatsapp_icon
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message