Technical mailing list archives

Re: Creating a docker image of odoo with some modules already installed

Chang Phui-Hock
- 10/13/2016 07:17:59

Did you run "docker commit" before "docker save"?

On Oct 13, 2016 19:11, "robert rottermann" <> wrote:

Hi Larry,

Am 13.10.2016 2:47 vorm. schrieb "ivange larry" <>:

Hi all

I am Larry, a software engineering intern. I need to create a docker image of odoo with some modules preinstalled for our implementation. I am new to both docker and odoo and am looking for some guidance on moving forward. I am hoping someone in the community has already done something. 

What I have done is pull the official odoo from docker hub, run it and installed all the modules we'll need. And did some customization(change logo, and company name)

Saved the image to a tar file using the following docker command
 docker save -o <save image to path> <image name>

I saved both the postgres image and the odoo image. So in another machine I tried loading the images and I was expecting that it will still have all the configuration I did. That is, it will already have all those modules installed and also the company related customization. But after loading the image and running it, I had a fresh odoo instance. 

So how can I create and image with some preinstalled modules and custom configurations packaged in the image.
I propose a different approach:
Dump the database to a file and reread it.
This can easily be done with the script and Dockerfile I added in the attached archive. assumes a folder structure as outlined in the README.txt below.
The odoo maker suite mentioned in the README allows to do this also across servers and different odoo sites.


# README.txt
# ----------
# dbdumper is part of the odoo maker suite found at
# it can be downloaded from:

create dbdumper image:
    to be able to do transfer data from/to a database within docker, we need a dbdumer image
    this can be created as follows:

        cd dumper
        # make sure that the ubuntu version used in the dockerfile
        # employs the same postgres version, as the one running in the container named 'db'
        docker build  -t dbdumper . # this creates the image
        test it:
            dbdumper assumes a directory layout as described under "use dbdumper image:"
            assuming that your odoo instances are in the folder /root/odoo_instances/root/odoo_instances
            you can run the following command:
                docker run -v /root/odoo_instances:/mnt/sites --rm=true --link db:db -it dbdumper -h

use dbdumper image:
    dbdumper expects the following directory layout
    BASEDIR can be any folder:
                additional addons (not used by dbdumper)
                to this folder the database will be dumped to / read from
                here is odoo's config file (not used by dbdumper)
                here are the external files stored (not used by dbdumper)(not used by dbdumper)
                here is odoos log file stored (not used by dbdumper)
                (not used by dbdumper)

create odoo docker container using folder structure:
    to create a docker container "afbstest" using the above lined out folder sturcture
    BASEDIR is /root/odoo_instances/ in this example:
    docker run -p \
        -v /root/odoo_instances/afbstest/etc:/etc/odoo \
        -v /root/odoo_instances/afbstest/addons:/mnt/extra-addons \
        -v /root/odoo_instances/afbstest/dump:/mnt/dump \
        -v /root/odoo_instances/afbstest/filestore:/var/lib/odoo/filestore \
        -v /root/odoo_instances/afbstest/log:/var/log/odoo \
        --name afbstest -d --link db:db -t odoo:9.0

I. Larry Ndumbe

Software Engineering Student, University of Buea
OpenMRS Volunteer Developer,
Google Summer of Code 2016 Student,
Odoo Implementer

Post to:

Post to:

Post to:

Post to: