Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Información
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

Set admin password with environment variables

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
developmentconfigurationenvironmentenv
2 Respuestas
8595 Vistas
Avatar
Daniel Rodriguez

Hi,


I'm currently using the Odoo 17 docker image and would like to set the admin_passwd config value using environment variables.


  1. I've tried but do]esn't seem to work. Can ayone confirm if this is possible? 
  2. If it isn't, what options do I have or how can I "merge" odoo.conf files?

Thanks!

0
Avatar
Descartar
Avatar
Gracious Joseph
Mejor respuesta

In Odoo, setting the admin_passwd value using environment variables in a Dockerized setup is not directly supported out of the box. However, you can work around this limitation using the following methods:

1. Use Environment Variables with the Docker Image

The Odoo Docker image does not natively support environment variables to directly configure admin_passwd. However, you can achieve this by modifying the entrypoint script or dynamically injecting the value into the odoo.conf file.

Steps:

  1. Set Environment Variable in Docker:
    • Define the environment variable in your docker-compose.yml or when running the container:
      environment:
        - ADMIN_PASSWORD=my_secure_password
      
  2. Modify the Entrypoint Script:
    • Extend the official Odoo Docker image by creating a custom entrypoint script that writes the environment variable into the odoo.conf file.
    Example Dockerfile:
    FROM odoo:17
    
    COPY entrypoint.sh /entrypoint.sh
    RUN chmod +x /entrypoint.sh
    
    ENTRYPOINT ["/entrypoint.sh"]
    CMD ["odoo"]
    
    Example entrypoint.sh:
    #!/bin/bash
    
    # Add the admin_passwd value to the odoo.conf file
    if [ -n "$ADMIN_PASSWORD" ]; then
        echo "admin_passwd = $ADMIN_PASSWORD" >> /etc/odoo/odoo.conf
    fi
    
    # Execute the original entrypoint command
    exec "$@"
    
  3. Rebuild and Run the Container:
    • Build the custom image:
      docker build -t custom-odoo .
      
    • Run the container with the environment variable:
      docker run -e ADMIN_PASSWORD=my_secure_password custom-odoo
      

2. Alternative: Dynamically Update odoo.conf

If you don’t want to modify the Docker image, you can dynamically write the environment variable into the odoo.conf file during container startup.

Steps:

  1. Mount a Script to Modify odoo.conf:
    • Write a script that reads the ADMIN_PASSWORD environment variable and appends it to /etc/odoo/odoo.conf.
    Example script set_admin_password.sh:
    #!/bin/bash
    
    if [ -n "$ADMIN_PASSWORD" ]; then
        echo "admin_passwd = $ADMIN_PASSWORD" >> /etc/odoo/odoo.conf
    fi
    
    exec "$@"
    
  2. Add the Script in docker-compose.yml:
    services:
      odoo:
        image: odoo:17
        environment:
          - ADMIN_PASSWORD=my_secure_password
        volumes:
          - ./set_admin_password.sh:/usr/local/bin/set_admin_password.sh
        entrypoint: ["bash", "/usr/local/bin/set_admin_password.sh"]
    
  3. Run the Container:
    • The script will dynamically update odoo.conf before the container starts.

3. Combine odoo.conf Files

If you want to merge configuration files, you can copy multiple configuration files into the container and specify which files to include.

Steps:

  1. Create Multiple conf Files:
    • Create a base configuration file (e.g., base.conf) and an additional file for the admin password (e.g., admin.conf).
    Example admin.conf:
    [options]
    admin_passwd = my_secure_password
    
  2. Modify the Entrypoint:
    • Use the --config option to load multiple configuration files.
    • For example:
      odoo --config=/etc/odoo/base.conf --config=/etc/odoo/admin.conf
      
  3. Automate This with Docker:
    • Copy multiple configuration files into the container:
      volumes:
        - ./base.conf:/etc/odoo/base.conf
        - ./admin.conf:/etc/odoo/admin.conf
      
    • Modify the CMD or entrypoint to include the merged configuration.

4. Use a Secret Management Tool

For production, storing sensitive information like admin_passwd in plain text environment variables is not recommended. Use a secret management tool like Docker Secrets or HashiCorp Vault.

Using Docker Secrets:

  1. Create a Secret:
    echo "my_secure_password" | docker secret create odoo_admin_password -
    
  2. Update docker-compose.yml:
    services:
      odoo:
        image: odoo:17
        secrets:
          - odoo_admin_password
    secrets:
      odoo_admin_password:
        file: /run/secrets/odoo_admin_password
    
  3. Update the Entrypoint Script:
    • Read the secret file and add it to odoo.conf:
      if [ -f /run/secrets/odoo_admin_password ]; then
          ADMIN_PASSWORD=$(cat /run/secrets/odoo_admin_password)
          echo "admin_passwd = $ADMIN_PASSWORD" >> /etc/odoo/odoo.conf
      fi
      
      exec "$@"
      

5. Verify the Setup

After implementing the changes, verify that the admin password is set correctly:

  1. Log in to Odoo.
  2. Go to Settings > Activate Developer Mode > General Settings.
  3. Ensure that the admin password is configured under the database management section.

Conclusion

  • While Odoo doesn’t directly support setting admin_passwd via environment variables, you can achieve this by modifying the entrypoint script or dynamically appending the value to odoo.conf.
  • For production environments, consider using secret management tools to enhance security. Let me know if you need further assistance!

1
Avatar
Descartar
Avatar
Dominik Ehrenberg
Mejor respuesta

Not sure what version Gracious Joseph used, but using multiple conf files with something like

odoo --config=/etc/odoo/base.conf --config=/etc/odoo/admin.conf

definitely does not work in Odoo 18. It will always use the last conf file provided

0
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
Dynamic Dashboard Background and Text on Dark/Light Theme Switch in Odoo 16 sh
development configuration
Avatar
Avatar
1
nov 25
249
Bulk PDF download error
development configuration
Avatar
0
oct 25
523
I am trying to set up a mass BOM edit. My Python code is giving forbidden opcode(s) error. Odoo 18
development configuration
Avatar
Avatar
Avatar
2
sept 25
1056
Google Calendar Sync - Odoo Calendar
development configuration
Avatar
Avatar
Avatar
3
ago 25
1985
Timesheets multiple days
development configuration
Avatar
Avatar
Avatar
3
jul 25
1313
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now