The Best

How to install Odoo with docker and add external modules

    0

    Basically, with this tutorial, you will learn how to install Odoo with docker and add external modules that will improve and extend the Odoo functionalities.

    Thanks to docker you can have any version of Odoo on the same computer and have multiple instances running, which will facilitate the development and start-up at any time, any organization and especially in any environment.

    The procedure is quite simple but I will try to do it as detailed as possible, the steps and procedures will focus on distros with Ubuntu 16.04 but they can be easily applied in any Linux distro.

    Also Read: How To Make Bootable Windows 10 USB Pendrive?

    Steps to install Docker and Docker Compose

    Install Docker

    To install Docker in Ubuntu, just execute the following command:

    sudo apt-get install docker.io

    Add your user to the Docker group

    We must execute the following command:

    sudo gpasswd -a ${USER} docker

    Install Docker-compose

    The easiest way to install Docker-ompose is to use pip, to do so, execute the following command:

    pip install docker-compose

    Install Docker-engine

    Install docker-engine with the following command:

    sudo curl -sSL https://get.docker.com/ | sh

    Restart Docker

    In order for all changes to be taken properly, it is convenient to restart the docker using:

    sudo service docker restart

    Creating our file docker-compose.yml

    Once we have installed docker, we must create the file docker-compose.yml  in the directory of our preference, it will contain basically all the information necessary to deploy our service with Odoo.

    nano docker-compose.yml

    This file will contain the following:

    version: '2'
    services:
      odoo:
        image: odoo: 8
        restart: always
        ports:
          - "8069: 8069"
        links:
          - db
        volumes:
          - ./extra-addons:/mnt/extra-addons
      db:
        image: postgres: 9.4
        restart: always
        environment:
          - POSTGRES_USER = odoo
          - POSTGRES_PASSWORD = odoo
    

    In this file we can make the following changes to adapt it to our requirements:

    • image: odoo:8 : You can replace odoo: 8 for the version you need odoo: 9, odoo: 10, odoo11 or simply odoo: latest for the latest version available.
    • ports: - "8069:8069": Replace the first port with the port you want, this will help you to have multiple instances of odoo running at the same time, for example, it could be this way,  ports: - "8070:8069"or  ports: - "8071:8069" and so on
    • image: postgres:9.4 : You can also replace the Postgres image that you want to use, particularly this version is doing quite well for me.

    In general terms with this docker-compose.yml we invoke a set of containers that are related to each other, as are the container of the odoo version and the Postgres container.

    Likewise, for the first container, we declare that it will listen to port 8069 ( and it will be possible to accede of which we indicate to him) and in addition mount a local volume called extra-addons that will be linked automatically with the / mnt / extra-addons of the container of odoo.

    Finally, the user and password to be used for Postgres are described and it is determined that when the host computer is restarted, the docker service will also do so, thanks to the restart: always parameter.

    Initial configuration of Odoo

    Once we have created our,docker-compose.yml we must start the instance of Odoo, for it from the terminal we are located in the directory where the previously created file is and we execute:

    docker-compose up -d
    

    Automatically the download of the necessary docker containers will start, the database will start and we will be able to access our odoo instance from localhost:8069or the port that you have indicated.

    Once in it, it will be necessary to create our database, for which we must choose the email, password, language, and language, in addition to selecting if we want to import test data to evaluate Odoo.

    install Odoo with docker

    Once the database is created, we can access odoo and start enjoying its benefits.

    Adding external modules to Odoo

    The docker-compose.yml  that we created in previous steps in addition to raising the necessary odoo and Postgres images also create a volume in our directory to be able to add external modules to our instance.

    To do this, it is enough to copy a module compatible with the version of odoo that we have executed in that directory, you can add your own modules or download it from Odoo apps.

    Once we have our module in the directory extra-addons ( unzipped ) that is in the directory where we have our docker-compose.yml , we proceed to give the corresponding permissions so that it can be read by our docker.

    The simple way is that located in the extra-addons parent directory, execute the following commands from the terminal:

    sudo chown -R lizard: lizard extra-addons / #replacing lizard by its user
    sudo chmod -R 755 extra-addons /

    Now from our instance of odoo we must activate the developer mode that depending on the version of odoo you have can be done as follows:

    Activate developer mode in Odoo 8

    The mode developed in Odoo 8 is activated from the User profiles, for this from the menu access the User category, locate your administrator user and in the lower right corner activate the features

    install Odoo with docker

    Activate developer mode in Odoo 9

    In Odoo 9 go to the top right and click on the date on the side of the user profile photo, then go to the About option and in the window that opens select Activate developer mode.

    install Odoo with docker

    Activate developer mode in Odoo 10 and Odoo 11

    To activate the developer mode in Odoo 10 and 11 we must go to the Configuration menu and in the lower right click on Activate developer mode.

    install Odoo with docker

    install Odoo with docker

    Finally, in any of the versions, we must go to the menu of local modules or apps and click on the link to update the list of modules.

    install Odoo with docker

    Installing packages in our docker

    It may be the case that any of the modules or utilities that you want to incorporate into odoo (or a characteristic of odoo itself) need the installation of external packages.

    This can be done quite easily in docker thanks to the fact  docker exec that it is a utility that allows us to execute commands in a docker container.

    The first thing we need to know is the name of our docker instance, which is done with the following command:

    docker ps

    To install an application in a docker as root, we must execute the following command adapting it to your needs:

    docker exec -u root odoo9_odoo_1 pip install xlsxwriter

    Where it docker exec -u root odoo9_odoo_1  tells us that a command will be executed as root in the instance odoo9_odoo_1 and  pip install xlsxwriter would be the command that you want to execute.

    Finally I would like to share several commands that will be useful when working with docker-composer

    # It runs from the directory of a docker instance and for the docker-compose that is running
    docker-composer stop
    # Run from the directory of a docker instance and start the docker-compose
    docker-composer start
    # Stop all containers
    docker stop $ (docker ps -a -q)
    # Remove all containers
    docker rm $ (docker ps -a -q)
    # Delete all images
    docker rmi $ (docker images -q)
    

    I hope the tutorial is to your liking, in next articles we will begin to learn to use Odoo and configure it in our SMEs.

    Varun Kesari
    Blogger | Youtuber | Music lover | Tech enthusiastic | Proud To be INDIAN