Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita 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
  • Proyectos
  • 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
8599 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.

Registrarse
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
250
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
1057
Google Calendar Sync - Odoo Calendar
development configuration
Avatar
Avatar
Avatar
3
ago 25
1987
Timesheets multiple days
development configuration
Avatar
Avatar
Avatar
3
jul 25
1315
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • 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 estar 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