Make sure you have:
-
GNU/Linux (any recent distribution)
-
Docker installed and running. You can check by running:
sudo docker --version
-
Git installed You can check by running:
sudo git --version
Follow these steps to clone the repository and run the script:
- Download the project from GitHub
git clone https://github.com/caprosoft/docker-odoo19 - Enter the project folder
cd docker-odoo19- Make the script executable
sudo chmod +x odoo19.sh- Run the script
sudo ./odoo19.shAfter running, Odoo will be available at http://localhost:8069
The script runs two Docker containers: one for the PostgreSQL database and one for Odoo.
#!/bin/sh
sudo docker run -d -v odoo-db:/var/lib/postgresql/data \
-e POSTGRES_USER=odoo \
-e POSTGRES_PASSWORD=odoo \
-e POSTGRES_DB=postgres \
--name db postgres:15
sudo docker run -d -v odoo-data:/var/lib/odoo \
-p 8069:8069 \
--name odoo \
--link db:db \
-t odooodoo-dbstores the PostgreSQL data, keeping it persistent even if the container is removed.odoo-datastores the Odoo application data, ensuring that your configurations and files are preserved.
If the containers already exist (e.g. after a system reboot or a manual stop), do not run the script again — just restart them.
⚠️ Important: Always startdbfirst, beforeodoo. If Odoo starts before the database is ready, it will fail to connect and throw an error.
# Restart containers (always db first!)
sudo docker start db odooTo stop them again:
sudo docker stop odoo dbIf you need to stop or remove the containers and volumes, use:
# Stop containers
sudo docker stop odoo db
# Remove containers
sudo docker rm odoo db
# (Optional) Remove volumes
sudo docker volume rm odoo-data odoo-dbTo recreate and re-run everything after cleanup, simply execute again:
sudo ./odoo19.shThis will rebuild the containers and restart your Odoo environment from scratch.
To have the containers start automatically at boot, you can create a systemd service.
✅ Requirement: The containers must already exist (i.e. the script
odoo19.shmust have been run at least once).
1. Create the service file
sudo nano /etc/systemd/system/odoo19.service2. Paste the following content
[Unit]
Description=Odoo 19 Docker Containers
Requires=docker.service
After=docker.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/sh -c 'docker start db && sleep 5 && docker start odoo'
ExecStop=/bin/sh -c 'docker stop odoo && docker stop db'
[Install]
WantedBy=multi-user.target💡 The
sleep 5gives PostgreSQL a few seconds to initialize before Odoo tries to connect.
3. Reload systemd and enable the service
# Reload systemd to pick up the new unit file
sudo systemctl daemon-reload
# Enable the service to start at boot
sudo systemctl enable odoo19.service4. Start / Stop / Check the service manually
# Start
sudo systemctl start odoo19.service
# Stop
sudo systemctl stop odoo19.service
# Check status
sudo systemctl status odoo19.service5. View logs
sudo journalctl -u odoo19.service