How it works...

docker-compose needs a YAML file to set up the services. In the YAML file, you will need to add the details of the services you want to deploy. After creating the YAML file, you can start all services in a single command.

In step 1, we created the YAML file for our services. To run the Odoo instance, we need two containers: one of the PostgreSQL database and one for Odoo itself. In the services: section we added two services. The first one is named web. This service is used to run the Odoo instance. In the service, you will need to specify the image name you want to containerize. So, in the web service, we have added odoo:12.0 as an image.

The Odoo instance cannot run without a database. Consequently, we need to specify the dependencies via the depends_on key. Next, we specified the service for PostgreSQL. We gave the name db to this service. Note that this is the same service that we added in the dependencies of the web service.

In step 2, we used the docker-compose command to run the Odoo instance. The docker-compose command will run the two containers. You can see the details with the docker ps command. After running the command, you can access Odoo through https://localhost:8069.

If you want to use custom add-ons or your own configuration, you can do so by specifying volumes in the docker compose YAML file like this:

version: '2'
services:
web:
image: odoo:12.0
depends_on:
- db
ports:
- "8069:8069"
volumes:
- odoo-web-data:/var/lib/odoo
- ./config:/etc/odoo
- ./addons:/mnt/extra-addons
db:
image: postgres:10
environment:
- POSTGRES_DB=postgres
- POSTGRES_PASSWORD=odoo
- POSTGRES_USER=odoo
- PGDATA=/var/lib/postgresql/data/pgdata
volumes:
- odoo-db-data:/var/lib/postgresql/data/pgdata
volumes:
odoo-web-data:
odoo-db-data:

The YAML file will run the Odoo instance with your custom add-ons and custom configuration. It also uses the volumes for the Odoo and PostgreSQL data directories.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset