Set Container Environment Variables
Some OCA modules and custom Odoo code read their configuration from Docker container environment variables rather than odoo.conf. OEC.sh lets you set these variables through the UI — they are injected at deploy time and survive every redeploy.
When to Use This
Use container environment variables when a module's documentation says to set an environment variable like:
ODOO_SESSION_REDIS=1
ODOO_SESSION_REDIS_HOST=my-redis-hostCommon examples:
| Module | Variables |
|---|---|
OCA session_redis2 | ODOO_SESSION_REDIS, ODOO_SESSION_REDIS_HOST, ODOO_SESSION_REDIS_PORT |
| Custom integrations | Any KEY=VALUE your code reads via os.environ.get("KEY") |
If a module reads from odoo.conf (like [options] key = value), use Settings → Odoo Configuration instead.
How to Set Environment Variables
Open Environment Settings
Go to your environment and click the Settings tab.
Open the Container Environment Variables section
Scroll to Container Environment Variables and click to expand it.
Add your variables
Type the variable name in the VARIABLE_NAME field and its value in the value field, then click Add (or press Enter).
Repeat for each variable you need.
Save
Click Save in the Container Environment Variables section.
Redeploy
Click Redeploy on the environment. The variables are injected on the next deploy — the currently running container is not affected until you redeploy.
Example: Redis Session Storage (OCA session_redis2)
The OCA session_redis2 (opens in a new tab) module stores Odoo sessions in Redis instead of the filesystem. It reads its configuration from container environment variables.
Your Redis instance must be reachable from within the Odoo container's Docker network. If you are running Redis yourself on the same server, use the container name (e.g. odoo-redis) not localhost.
Set these variables:
| Name | Value | Description |
|---|---|---|
ODOO_SESSION_REDIS | 1 | Enable Redis session storage |
ODOO_SESSION_REDIS_HOST | odoo-redis (or your Redis hostname) | Redis host |
ODOO_SESSION_REDIS_PORT | 6379 | Redis port (default) |
After saving and redeploying, verify sessions are going to Redis:
docker exec -it <your-redis-container> redis-cli
> KEYS odoo:session:*Validation Rules
| Rule | Detail |
|---|---|
| Key format | Must match ^[A-Za-z_][A-Za-z0-9_]*$ — starts with a letter or underscore, only letters, digits, underscores |
| Max variables | 100 per environment |
| Max key length | 256 characters |
| Max value length | 4096 characters |
Do not store passwords or secrets here. Values are stored as plaintext in the database and returned in API responses. Use odoo.conf settings or a secrets manager for sensitive values.
Platform-Managed Keys
The platform automatically sets these thread-limit variables to 1 to prevent Odoo from overloading the server. If your workload benefits from higher values, add them to override the platform default:
| Key | Platform Default | Override Example |
|---|---|---|
OPENBLAS_NUM_THREADS | 1 | 4 |
OMP_NUM_THREADS | 1 | 4 |
MKL_NUM_THREADS | 1 | 4 |
Your value always wins — the platform default only applies if you have not set the key yourself.