Enable Dark Mode!
odoo-14-deployment-using-docker.jpg
By: Abdul Afras

Odoo 14 Deployment using Docker

Technical Odoo 14

Docker is a platform for application-level deployment that allows developers and users to build, deploy, run, and manage their apps using containers. These containers allow developers to combine different components of their software into a single instance to build packages/tools/environments/libraries etc. By doing this, developers in any other environment can run their applications without thinking about their variations in dependency. Moreover, in reality, 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.
Considering Odoo image it has all the required packages and libraries making the Odoo run with ease.
To deploy Odoo on Docker, initially, we needed to set-up two docker containers. We can use the Postgres image and Odoo image for that.
1. Odoo Image: There is an official image of the Odoo in the Docker hub which can be installed into the Docker Container
2. 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.

Docker-Compose:
We are using Docker-compose to run multiple containers in a single service. In Odoo, it requires Odoo and PostgreSQL, we can create a file that includes both containers and we can start both the containers as a service as there is no necessity to start them individually.
Here I will be explaining how to run Odoo 14 using docker-compose.

Installing Docker-Compose:
Execute this 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
Now we can 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 #the data directory to hold the odoo data and postgres data 

Adding the contents into ./docker-compose.yml:
Sample docker-compose file is given below.
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 need to map the port on the host machine(left side) to the
#Port inside the container on the right. By 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:
  - 9000: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:/mnt/extra
        - ./enterprise:/mnt/enterprise
#Username and password of the Host DB
# Make sure to give the same credentials
#inside the postgres service
environment:
  - HOST=db
  - 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 configuration 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 = /mnt/extra-addons , /mnt/enterprise
proxy_mode = True
data_dir = /var/lib/odoo
To 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:9000.
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 package inside the 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


Odoo Training Package
Odoo Implementation Package

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


cybrosys youtube

0
Comments



Leave a comment

 
whatsapp
location
Calicut

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

location
London

Cybrosys Limited
Alpha House,
100 Borough High Street, London,
SE1 1LB, United Kingdom

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