Running Odoo Using Docker Compose
Include sharing custom/additional addons


What is Docker?

Docker is an open source platform that enables developers to build, deploy, run, update and manage containers—standardized, executable components that combine application source code with the operating system (OS) libraries and dependencies required to run that code in any environment.

How Docker works?

Docker works by providing a standard way to run your code. Docker is an operating system for containers. Similar to how a virtual machine works in virtualizing (removes the need to directly manage) server hardware, containers virtualize the operating system of a server. Docker is installed on each server and it provides simple commands you can use to build, start, or stop containers.

About "How/Where to install Docker?"  you can find it easily on https://docs.docker.com/ 


Prerequisite:

Make sure you have Docker & Docker Compose installed.

Let's start!

1. Create project directory on your system to store the config and etc.

mkdir -p ~/projects/odoo-docker
cd ~/projects/odoo-docker
touch docker-compose.yml
mkdir ./config && touch config/odoo.conf
mkdir ./addons
  • projects: root directory for docker-container
  • odoo-docker: container directory
  • docker-compose.yml:  config file for Docker Compose
  • /config: put your Odoo configuration here 
  • odoo.conf: your odoo config file
  • /addons: put your customsaddons here

2. Add services inside docker-compose.yml


  • version:  docker-compose file (latest version) is recommended
  • services: contain some container definition
  • web: container attribute
  • image: docker images
  • depends_on:  it means this container depends to "db" container, so the docker-compose will not create this container before "db" container is ready
  • ports: define port for this container when it's running
  • volumes: define where to store/mount the container data. It can use "docker volumes" or   your local directory.  In production, it's strongly recommended by using docker volume since it's support "docker-compose" backup, restore or migrate the data
  • environments: define environment variable

3. Add odoo.conf to ./config/odoo-conf

This configuration will be used by docker container "web" above. So be careful about addons_path, xmlrpc_port, db_user & db_password, all those value should be exact as defined in the docker-compose.yml above



  • addons_path: from the volume that we've created before it should be defined here so your custom addons will be displayed on Odoo List Apps

4. Run the Container

You can start up the container by using:

docker-compose up -d

After you run the command above, you'll see the docker-compose is creating container that you've been defined above without some detail information, because -d means all the process is on the background (daemon).  If you want see detail information about the output from the Odoo "web" and Postgre "db" process, just remove -d. Once it has completed, you can access your deployment on "http://localhost:8072"

Common command-line:

# Start containers 
$ docker-compose up
# Start containers up in the background $ docker-compose up -d # Restart containers $ docker-compose restart # Stop containers $ docker-compose stop # Destroy containers (WARNING: This could mean data inside those containers as well) $ docker-compose down # Show container processes $ docker ps $ docker ps --filter name={container_name} # Show container process stats $ docker stats


Notes:

With all configurations above, we can easily deploy/run multiple Odoo process by several step:

  • duplicate the odoo-docker folder inside the projects folder and give it different name (as deployment requested)
  • modify docker-compose.yml, change the ports under Odoo "web" container
  • modify odoo.conf inside config folder, set the xmlrpc_port exact with Odoo "web" container ports.
Panemu Solusi Industri, Mubin 26 Oktober, 2022
Share this post
Archive
Sign in to leave a comment
Flutter Infinite Scroll dengan BLOC State Management