Docker allows you to package your Odoo application with its dependencies into a lightweight, portable container. This container isolates Odoo’s processes and resources, ensuring consistent behavior regardless of the underlying environment. Compared to traditional deployments, Docker containers offer:
Portability: Run Odoo seamlessly across different machines (Windows, macOS, Linux) without worrying about environment conflicts.
Resource Efficiency: Containers share the host operating system’s kernel, making them lighter and faster to start than virtual machines.
Isolation: Each Odoo instance runs in its own container, preventing conflicts with other applications sharing the system.
Uninstall old versions
Before you can install Docker Engine, you need to uninstall any conflicting packages.
for pkg in docker.io docker-doc docker-compose docker-compose-v2
podman-docker containerd runc; do sudo apt-get remove $pkg; done
Step 1 – Installing Docker on Ubuntu 22.04 LTS
Installation
Install using the apt repository:
Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.
$ sudo apt-get update
$ sudo apt-get install ca-certificates curl
$ sudo install -m 0755 -d /etc/apt/keyrings
$ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
$ sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
“deb [arch=$(dpkg –print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo “$VERSION_CODENAME”) stable” | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get install docker-ce docker-ce-cli containerd.io
docker-compose-plugin docker-compose
$ sudo apt-get update
$ docker –version
- Other installations methods you can check it here: Install Docker Engine on Ubuntu | Docker Docs
Step 2 - Installing Docker Compose:
To install the docker-compose command line tool, refresh your package list, then install the package using apt:
$ sudo apt update
$ sudo apt install docker-compose
You can confirm that the package is installed by running the following command:
$ docker-compose –version
Step 3 — Running Odoo and PostgreSQL with Docker Compose:
Run the following commands to create the directory and then cd into it:
$ mkdir -p ~/docker/odoo
$ cd ~/docker/odoo
Now open a new blank YAML file called docker-compose.yml using nano or your preferred editor:
$ nano docker-compose.yml
Add the following lines to the file:
Create a ‘myenvfile.env’ file:
$ nano myenvfile.env
Add these environment variables to it.
#postgresql env variables
POSTGRES_DB=postgres #name of the PostgreSQL db that will be created or used by the PostgreSQL server.
POSTGRES_PASSWORD=odoo17 #db_user
POSTGRES_USER=odoo17 #db_password
PGDATA=/var/lib/pgsql/data/pgdata #storage location of DBs and data files of PSQL
# odoo env variables
HOST=db
USER=odoo17
PASSWORD=odoo17
You’re now ready to start the odoo and postgres containers with the docker-compose command:
docker-compose up –d
The up sub-command tells docker-compose to start the containers and the associated volumes and networks that are defined in the docker-compose.yml file. The -d flag (which stands for “daemonize or detached ”) tells docker-compose to run the containers in the background so the command doesn’t take over your terminal.
When that’s done, Odoo should be running. You can test that a webserver is running at 127.0.0.1:8069(Server IP Address) or localhost://8069
If you would like to stop your Odoo and PostgreSQL containers at any time, run the following command in your ~/docker/odoo directory:
docker-compose down
We’re thrilled to announce upcoming blog posts that will guide you through Odoo deployment and automation!
- Effortless Odoo with Custom Addons via Docker: Explore how to leverage Docker containers for streamlined Odoo deployment, including the seamless integration of your custom addons.
- Automate Your Odoo Journey: CI/CD for Containerized Odoo Applications: Discover the power of CI/CD pipelines to automate the containerization and deployment process for your custom Odoo applications, ensuring efficiency and consistency.