Skip to Content
Menu
This question has been flagged
2 Replies
3319 Views

I am using Ubuntu 22.04, current OS user is 'odoo'.

I want to install Odoo using Docker for development. I will create all Docker Containers for different versions of Odoo (like 15,16,17...) after successfully created one, I want to keep versions separate in their Containers.

I searched Internet for same but yet failed to find about is there any need to install Python3 and Pycharm within Docker Container or Not?

if Not then how I can install and done development tasks using Python3, PostgreSQL and Pycharm? how to configure Pycharm for all installed versions and anything else too?

it's humble request to the community members to please help.

with regards


Avatar
Discard
Author

any hope to get help ???

Author

thank you very much @Gracious Joseph for reply and detailed guidance, very few people can do it. i will check it and reply here.

with kind regards


Author Best Answer

hi @Gracious Joseph

i tried to follow as per your instructions as below, just made one change in your ~/odoo_docker/odoo16/docker-compose.yml file, I used image: postgres:16 instead of postgres:13:


odoo@odoo-VirtualBox:~$ pwd

/home/odoo

sudo apt install -y docker(dot)io docker-compose

sudo systemctl start docker

sudo systemctl enable docker

odoo@odoo-VirtualBox:~$ mkdir odoo-docker

odoo@odoo-VirtualBox:~$ cd odoo-docker

odoo@odoo-VirtualBox:~$ mkdir odoo15

odoo@odoo-VirtualBox:~$ mkdir odoo16

odoo@odoo-VirtualBox:~$ mkdir odoo17

odoo@odoo-VirtualBox:~$ cd ~/odoo-docker/odoo16

doo@odoo-VirtualBox:~/odoo-docker/odoo16$ sudo docker-compose up -d

[sudo] password for odoo:

Creating network "odoo16_default" with the default driver

Pulling odoo (odoo:16)...

16: Pulling from library/odoo

Digest: sha256:2ec9878811bc973198e1683c03e758344c4232ee88fcd8409ed444b9179a13ca

Status: Downloaded newer image for odoo:16

Creating odoo16-db ... done

Creating odoo16    ... done


odoo@odoo-VirtualBox:~/odoo-docker/odoo16$ ls -la

total 24

drwxrwxr-x  5 odoo             odoo 4096 Dec  9 10:59 .

drwxrwxr-x  5 odoo             odoo 4096 Dec  9 10:43 ..

-rw-rw-r--  1 odoo             odoo  565 Dec  9 10:53 docker-compose.yml

drwxr-xr-x  2 root             root 4096 Dec  9 10:57 odoo_addons

drwxr-xr-x  2 root             root 4096 Dec  9 10:57 odoo_data

drwx------ 19 systemd-coredump root 4096 Dec  9 10:57 postgres_data

odoo@odoo-VirtualBox:~/odoo-docker/odoo16$ sudo chown -R odoo:odoo odoo_addons

odoo@odoo-VirtualBox:~/odoo-docker/odoo16$ sudo chown -R odoo:odoo odoo_data

odoo@odoo-VirtualBox:~/odoo-docker/odoo16$ ls postgres_data/

ls: cannot open directory 'postgres_data/': Permission denied

odoo@odoo-VirtualBox:~/odoo-docker/odoo16$ sudo chown -R odoo:odoo cd

[sudo] password for odoo:

odoo@odoo-VirtualBox:~/odoo-docker/odoo16$

odoo@odoo-VirtualBox:~/odoo-docker/odoo16$  docker-compose up -d

ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.


when running with: 

doo@odoo-VirtualBox:~/odoo-docker/odoo16$ sudo docker-compose up -d

odoo16-db is up-to-date

odoo16 is up-to-date

and trying to access in web browser http://localhost:8069 it is not showing odoo initial page instead below errors.

Unable to connect

Firefox can’t establish a connection to the server at localhost:8015.


here i stuck for the above and also for last folder postgres_data, can't change owner:group and permission, how i can test things will work fine or not.

please advise

with kind regards

Avatar
Discard
Best Answer

Setting up Odoo with Docker for development on Ubuntu 22.04 is a practical approach, especially when working with multiple Odoo versions like 15, 16, and 17. Here’s a comprehensive guide tailored to your requirements:

1. Prerequisites

Before starting, ensure you have the following installed on your Ubuntu system:

  • Docker and Docker Compose:
    bashCopy codesudo apt update
    sudo apt install -y docker.io docker-compose
    sudo systemctl start docker
    sudo systemctl enable docker
    
  • Python 3.x (for development outside Docker if needed):
    bashCopy codesudo apt install python3 python3-pip
    

2. Set Up Directory Structure

Organize your project for multiple Odoo versions. For example:

javascriptCopy code~/odoo_docker/
├── odoo15/
├── odoo16/
└── odoo17/

Each version will have its Docker Compose file, configuration, and optional custom modules directory.

3. Create Docker Compose File

Create a docker-compose.yml file for each version in its respective folder.

Example for Odoo 16 (~/odoo_docker/odoo16/docker-compose.yml):

yamlCopy codeversion: '3.1'

services:
  db:
    image: postgres:13
    container_name: odoo16-db
    environment:
      - POSTGRES_USER=odoo
      - POSTGRES_PASSWORD=odoo
      - POSTGRES_DB=postgres
    volumes:
      - ./postgres_data:/var/lib/postgresql/data
    restart: always

  odoo:
    image: odoo:16
    container_name: odoo16
    depends_on:
      - db
    ports:
      - "8069:8069"
    environment:
      - HOST=db
      - USER=odoo
      - PASSWORD=odoo
    volumes:
      - ./odoo_addons:/mnt/extra-addons
      - ./odoo_data:/var/lib/odoo
    restart: always

4. Start Docker Containers

Navigate to the folder for the desired version and start the containers:

bashCopy codecd ~/odoo_docker/odoo16
docker-compose up -d
  • The database will persist in the postgres_data volume.
  • Additional custom modules can be added to the odoo_addons directory.

Repeat for other versions (15, 17) by creating separate configurations.

5. Configure Pycharm for Development

To use PyCharm for Odoo development:

  1. Install PyCharm: Download and install PyCharm Professional or Community edition from JetBrains.
  2. Configure PyCharm with Docker Interpreter:
    • Open PyCharm and go to Settings > Project > Python Interpreter.
    • Add a new interpreter and choose Docker.
    • Select the Odoo Docker container (e.g., odoo16) as the interpreter.
    • This allows PyCharm to use the Python environment inside the Docker container for development.
  3. Set Up Project Folder:
    • Add the Odoo source code (if available) and the odoo_addons directory to your project in PyCharm.
    • Configure Odoo's addons path in the container to include mnt/extra-addons.

6. Development Workflow

  • Modify or create custom modules in odoo_addons.
  • Restart the Odoo container to apply changes:
    bashCopy codedocker-compose restart odoo
    
  • Access Odoo at http://localhost:8069 for testing.

7. Managing Multiple Versions

Each version runs independently in its Docker container with its database. To avoid port conflicts:

  • Change the exposed port for each version in the docker-compose.yml:
    yamlCopy codeports:
      - "8070:8069"  # For Odoo 15
      - "8071:8069"  # For Odoo 17
    

8. Best Practices

  • Use Docker volumes to persist data and avoid losing work.
  • Use the same PostgreSQL user/password for consistency across containers.
  • If you need to test Python dependencies, install them directly in the container or on the host system.

9. Advanced Setup

  • Enable Debugging in PyCharm:
    • Set breakpoints in your custom module.
    • Configure the Docker container to run in debug mode.
  • Use VSCode as an Alternative:
    • Install the Remote - Containers extension for developing inside Docker.

Example Commands

  • Stop a specific container:
    bashCopy codedocker-compose down
    
  • View container logs:
    bashCopy codedocker logs odoo16
    
  • Remove all containers and volumes:
    bashCopy codedocker-compose down -v
    

Summary

With this setup:

  • Each Odoo version is isolated in its Docker container.
  • Development can be done using PyCharm or other tools with Docker integration.
  • PostgreSQL and custom modules are managed separately for each version.

Feel free to ask if you need further clarification or assistance with specific configurations!

Avatar
Discard
Related Posts Replies Views Activity
1
Nov 22
3214
1
Nov 20
5390
6
Jun 20
21283
0
Jun 20
9777
1
Jul 19
18750