Skip to content

Odoo 17 Docker setup with PostgreSQL, Supervisor, and single volume for persistent data storage.

Notifications You must be signed in to change notification settings

mabt-tech-com/Docker-Odoo17

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Odoo 17 Docker Setup with Single Volume

This guide will help you set up Odoo 17 in a Docker container with a single volume for persistent data storage. You can use this guide to run the setup on both Docker Desktop (Windows) and Ubuntu Server VPS.

Prerequisites

  • Docker Desktop installed on Windows or Docker installed on Ubuntu Server VPS.
  • An Odoo 17 Docker image (iifast2/odoo17-img:1.0) with PostgreSQL and Supervisor installed.

Dockerfile Overview

Here is the Dockerfile used to set up Odoo with a single volume that stores all necessary files (PostgreSQL data, Odoo logs, and configuration):

# Use your pulled Docker image as the base image
FROM iifast2/odoo17-img:1.0

# Update and install necessary packages if missing
RUN apt-get update && apt-get install -y \
    postgresql \
    supervisor \
    && rm -rf /var/lib/apt/lists/*

# Expose the necessary port for Odoo
EXPOSE 8069

# Define a single Docker volume for all necessary files
VOLUME ["/data"]

# Command to start all necessary services when the container is run
CMD service postgresql start && \
    service supervisor start && \
    supervisorctl start odoo17 && \
    tail -f /data/odoo17/odoo17.log

This Dockerfile does the following:

  • Installs PostgreSQL and Supervisor (if needed).
  • Exposes port 8069 for Odoo’s web interface.
  • Defines a single volume (/data) where PostgreSQL data, Odoo logs, and configuration files will be stored.
  • Starts PostgreSQL, Supervisor, and Odoo when the container is run.

Running the Container on Docker Desktop (Windows)

Step 1: Prepare the Host Directory

Create a directory on your Windows machine that will serve as the persistent volume for the container. For example:

C:/Users/yourusername/Desktop/odoo-data

Step 2: Run the Container

Use the following command to run the container with the volume mapped to your host directory:

docker run -d -p 8069:8069 --name odoo17-container \
  -v C:/Users/yourusername/Desktop/odoo-data:/data \
  odoo17-img-with-services

Explanation:

  • -p 8069:8069: Maps port 8069 on the container to port 8069 on your Windows machine. You will access Odoo at http://localhost:8069.
  • -v C:/Users/yourusername/Desktop/odoo-data:/data: Maps your host directory (C:/Users/yourusername/Desktop/odoo-data) to the container's /data directory. This will store PostgreSQL data, Odoo logs, and configuration files in a single location on your Windows machine.
  • odoo17-img-with-services: The Docker image that runs Odoo, PostgreSQL, and Supervisor.

Step 3: Access Odoo

After the container is running, open your web browser and navigate to:

http://localhost:8069

You should see the Odoo web interface.

Running the Container on Ubuntu Server VPS

Step 1: Prepare the Host Directory

Create a directory on your Ubuntu VPS that will serve as the persistent volume for the container. For example:

mkdir -p /path/on/host/data

Step 2: Run the Container

Use the following command to run the container on your Ubuntu VPS:

docker run -d -p 8069:8069 --name odoo17-container \
  -v /path/on/host/data:/data \
  odoo17-img-with-services

Explanation:

  • -p 8069:8069: Maps port 8069 on the container to port 8069 on your VPS. You will access Odoo at http://<your-vps-ip>:8069.
  • -v /path/on/host/data:/data: Maps your host directory on the VPS (/path/on/host/data) to the container's /data directory. This will store PostgreSQL data, Odoo logs, and configuration files in a single location on your VPS.

Step 3: Access Odoo

Once the container is running, access Odoo by opening your browser and navigating to:

http://<your-vps-ip>:8069

You should see the Odoo web interface.

Understanding the Volume Mapping

The -v flag maps a directory on your host machine to a directory inside the Docker container. This allows you to persist files across container restarts, and makes it easier to access or manage these files.

  • On Windows: The host directory might look like C:/Users/yourusername/Desktop/odoo-data.

  • On Ubuntu VPS: The host directory might look like /path/on/host/data. Inside the container, the mapped directory is /data, and it contains:

  • /data/postgresql: PostgreSQL data for your Odoo database.

  • /data/odoo17: Odoo log files.

  • /data/config: Configuration files for Odoo. This setup consolidates everything into a single volume, making backups and management much simpler.

Troubleshooting

Container Exits Immediately After Starting If the container exits immediately, check the logs using:

docker logs odoo17-container

This will provide details about what might have gone wrong during startup.

File Permissions

If you encounter permission issues accessing the files in the volume, ensure that the permissions on the host directory are set correctly. You may need to adjust file permissions or ownership.

Conclusion

This setup allows you to run Odoo in a Docker container while persisting important files such as logs, configuration, and databases using a single volume. This makes it easy to access and manage files from both Windows and Ubuntu Server VPS.









Run instructions & Dockerfile :

# Use your pulled Docker image as the base image
FROM iifast2/odoo17-img:1.0

# Update and install necessary packages
RUN apt-get update && apt-get install -y \
    postgresql \
    supervisor \
    && rm -rf /var/lib/apt/lists/*

# Copy your custom supervisor configuration file if you have one
# COPY odoo17.conf /etc/supervisor/conf.d/odoo17.conf

# Expose the necessary port
EXPOSE 8069

# Command to start all necessary services when the container is run
CMD service postgresql start && \
    service supervisor start && \
    supervisorctl start odoo17 && \
    tail -f /var/log/odoo17/odoo17.log

docker build -t odoo17-img-with-services .
docker run -d -p 8069:8069 --name odoo17-container odoo17-img-with-services




CMD service postgresql start && \
    service supervisor start && \
    supervisorctl start odoo17 && \
    tail -f /var/log/odoo17/odoo17.log


Files inside container and thier paths :

/opt/odoo17
/usr/bin/python3.10
/etc/odoo17.conf
/etc/supervisor/conf.d/odoo17.conf
/var/log/odoo17

odoo 17 config file (/etc/supervisor/conf.d/odoo17.conf) :

admin_password = admin
db_user = odoo17
addons_path = /opt/odoo17/addons
logfile = /var/log/odoo17/odoo17.log


sudo su - postgres
sudo supervisorctl start odoo17
sudo supervisorctl status

Enable Supervisor to Start at Boot

To make sure Supervisor starts automatically when the container starts, you should add the following to your Dockerfile or entrypoint script:

CMD ["supervisord", "-n"]

Releases

No releases published

Packages

No packages published