To run Odoo on docker, we have to set-up two docker containers. For that, we can use docker images
1. Odoo Image: Odoo has an official image (Odoo Image) on Docker in order to install Odoo on the Docker virtual environment.
2. Postgress Image: Odoo uses Postgres SQL to store and manipulate its data. So before configuring Odoo image, we have to make sure that a Postgres image is properly running on our docker environment.
Install docker(Ubuntu 18.04)
In the consideration to install docker initially, we have to make sure that every required package is properly installed in the system in order to run the docker which can be ensured using the following command:
Get a GPG key for better maintenance and security using the following command:
Now get a stable version of the Docker repository using the following command:
Update the system packages.
Install Docker(Here, we are installing the community edition)
Add a user to the docker group using the following command:
Once every mentioned step is complete, you can check whether the Docker is installed properly or not by using a simple hello world command.
Install Odoo on the docker
We have successfully installed Docker on the system. Now we have to install the Odoo image on the docker. A running PostgreSQL should be there in order to run the Odoo image on the docker. So, before going to Odoo image, we have to make sure that a Postgres image runs properly on the docker environment.
To install Postgres image use the following code:
Now install Odoo image by using the following code:
Odoo tries to find the name ‘db’ of the Postgres container. So in order to connect the Odoo with PostgreSQL, the alias of the Postgres container should be ‘db’.
You can use your custom conf file in the Odoo container by using the following code:
While starting, Odoo will find the custom conf file from the /custom/conf/path which can be done using the following command:
If you want to include custom addons, use the /mnt/extra-addons volume.
Set-up a docker-compose.yml
Create a docker-compose.yml file that contains all the basic information about the Odoo-container and the database container. Here is the simplest one:
You can change the configuration to make as your requirement:
* web/image: Version of the Odoo
* The default port will be 8069:8069, By changing the first port, you will be able to have multiple Odoo instances simultaneously.
* db/image: Version of the Postgres image.
As we have an understanding of the installation aspect of Odoo 13 using a docker let's now look in the next section on certain useful commands that will be usable in the operations to simplify the tasks.
Here is a list of useful command that will be helpful in installing Odoo 13 using a docker:
* Run docker. Take a look
* docker start container_name (Start docker with a container)
* docker restart container_name (Restart docker with a container)
* docker stop container_name (Stop docker with a container)
* docker-compose up -d (To start an Odoo instance. The directory should be the same where the docker-compose.yml file exists)
* docker run -p 8070:8069 --name odoo1 --link db:db -t odoo
docker run -p 8071:8069 --name odoo2 --link db:db -t odoo
To start multiple Odoo instances at a time, make sure that the PostgreSQL container’s alias name is db otherwise, Odoo won’t recognize and consider the command. In addition, you can have any number of Odoo instances at a time by changing its port.