Odoo in Docker Container

Containerized Odoo with Docker persistent storage and networking

How to install Odoo in Docker containers?

Docker containers make it easy for Odoo.

1. Install Docker:

    1. Update and Install Docker CE:

       $ sudo apt-get update && sudo apt install apt-transport-https ca-certificates curl software-properties-common -y

    2. Add Docker’s official GPG key:

       $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

    3. Use the following command to set up the stable repository:

        $ sudo add-apt-repository \
           "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
           $(lsb_release -cs) \

    4. Install the latest version of Docker CE or specific version:

        $ sudo apt update && sudo apt install docker-ce -y
        $ sudo apt update && sudo apt-get install docker-ce=<VERSION>

    5. If you would like to use Docker as a non-root user, you should now consider adding your user to the "docker" group         with something like:

        $ sudo usermod -aG docker your-user

        Remember that you will have to log out and back in for this to take effect!

        WARNING: Adding a user to the "docker" group will grant the ability to run
                 containers which can be used to obtain root privileges on the
                 docker host.
                 Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
                 for more information.

    6. If Above step did not work try this:

        $ cd /var/run
        $ ls -lrth docker.sock
        $ sudo chmod 666 /var/run/docker.sock
        $ ls -lrth docker.sock

    7.  Running Docker:

        $ sudo docker run hello-world

We successfully installed docker on ubuntu system and now going to setup Odoo using the docker. Odoo uses the PostgreSQL database which is a different application. So, we are going to create one container for the PostgreSQL database server and one for Odoo application. By doing this we can able to create multiple Odoo instances using one PostgreSQL database server instance.

2. Installing Odoo In Docker Container:

        1. Start a PostgreSQL server:

        $ docker run -d -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo -e POSTGRES_DB=postgres --name db postgres:<database server version>

        2. Start an Odoo instance:

        $ docker run -p 8069:8069 --name odoo --link db:db -t odoo:<Odoo Version>

The alias of the container running Postgres must be DB for Odoo to be able to connect to the Postgres server.

We published Odoo web service in port 8069 so you can navigate to http://localhost:8069. If you use Docker in a virtual machine you have to change localhost to the IP-address of your Docker virtual machine, e.g.

Odoo starts with a welcome page and you are able to create your Odoo database. The creation takes less than a minute. After that, you can install apps and start using Odoo.

After you create the database, remember to change the master password if your Odoo web pages are accessible to other users.

        3. Starting and stopping Odoo containers:

                a. Found container id of Odoo:

                $ docker ps

                b. Stop Odoo instance:

                $ docker stop odoo

                c. Start Odoo instance:

                $ docker start odoo

                d. Restart Odoo Instance:

                $ docker restart odoo

        4. Stop and restart a PostgreSQL server:

            When a PostgreSQL server is restarted, the Odoo instances linked to that server must be restarted as well 
            because the server address has changed and the link is thus broken.

            Restarting a PostgreSQL server does not affect the created databases.

       5. Run Odoo with a custom configuration:

            The default configuration file for the server (located at /etc/odoo/odoo.conf) can be overridden at startup             using volumes. Mounting customer add-ons or Odoo Enterprise add-ons using <b>`composer.yml`</b> file.

            a. Install docker-composer:

                $ sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose    

                Next, we’ll set the permissions:

                $ sudo chmod +x /usr/local/bin/docker-compose

                Then we’ll verify that the installation was successful by checking the version:

                $ docker-compose --version

            b. Running a Container with Docker Compose :

                First, we’ll create a directory for the YAML file and move into it:

            $ mkdir odoo-docker
            $ cd odoo-docker

                Then, we’ll create the YAML file:

            $ nano docker-compose.yml

                Put the following contents into the file, save the file, and exit the text editor:

                Now, while still in the ~/hello-world directory, we’ll execute the following command:

            $ docker-compose up -d
         -d : For start service in background


Odoo source code can be found from GitHub here: https://github.com/odoo/odoo. You can find also the official Odoo Docker images in Odoo GitHub repository here: https://github.com/odoo/docker.

Docker Store has the official Odoo container here: https://hub.docker.com/_/odoo/. The image is based on the Dockerfile found in odoo/docker repository. PostgreSQL image is also available on Docker Hub: https://hub.docker.com/_/postgres/.

If you have questions about how to use Odoo or container technologies in your business, I am happy to answer them and help you.  :)