Run container as user.
Open
Nobody has claimed this yet.
- Dominant language
- Dockerfile
- Stars
- 1.2k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
Hi
When trying to run the container as a specify user it wont work.
KeyError: 'getpwuid(): uid not found: 1000'
Traceback (most recent call last):
File "/usr/bin/odoo", line 8, in <module>
odoo.cli.main()
File "/usr/lib/python3/dist-packages/odoo/cli/command.py", line 61, in main
o.run(args)
File "/usr/lib/python3/dist-packages/odoo/cli/server.py", line 179, in run
main(args)
File "/usr/lib/python3/dist-packages/odoo/cli/server.py", line 126, in main
check_root_user()
File "/usr/lib/python3/dist-packages/odoo/cli/server.py", line 40, in check_root_user
if getpass.getuser() == 'root':
File "/usr/lib/python3.9/getpass.py", line 169, in getuser
return pwd.getpwuid(os.getuid())[0]
KeyError: 'getpwuid(): uid not found: 1000'
docker-compose.yml file
odoo:
container_name: odoo
hostname: odoo
image: odoo:15
restart: unless-stopped
volumes:
- /opt/odoo/odoo/data/web-data:/var/lib/odoo
- /opt/odoo/odoo/data/addons:/mnt/extra-addons
ports:
- "127.0.0.1:8069:8069"
user: "1000:1000"
env_file:
- '/opt/odoo/odoo/env-odoo-config'
networks:
- odoo-network
depends_on:
- db
When removing the user.
2022-09-15 07:42:41,457 1 INFO ? odoo: Odoo version 15.0-20220902
2022-09-15 07:42:41,458 1 INFO ? odoo: Using configuration file at /etc/odoo/odoo.conf
2022-09-15 07:42:41,458 1 INFO ? odoo: addons paths: ['/usr/lib/python3/dist-packages/odoo/addons', '/mnt/extra-addons']
2022-09-15 07:42:41,458 1 INFO ? odoo: database: odoo@db:5432
2022-09-15 07:42:41,669 1 INFO ? odoo.addons.base.models.ir_actions_report: Will use the Wkhtmltopdf binary at /usr/local/bin/wkhtmltopdf
2022-09-15 07:42:41,986 1 INFO ? odoo.service.server: HTTP service (werkzeug) running on odoo:8069
2022-09-15 07:43:18,053 1 INFO ? werkzeug: 172.21.0.1 - - [15/Sep/2022 07:43:18] "GET / HTTP/1.0" 500 - - - -
2022-09-15 07:43:18,057 1 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/werkzeug/serving.py", line 323, in run_wsgi
execute(self.server.app)
File "/usr/lib/python3/dist-packages/werkzeug/serving.py", line 312, in execute
application_iter = app(environ, start_response)
File "/usr/lib/python3/dist-packages/odoo/service/server.py", line 482, in app
return self.app(e, s)
File "/usr/lib/python3/dist-packages/odoo/service/wsgi_server.py", line 112, in application
return application_unproxied(environ, start_response)
File "/usr/lib/python3/dist-packages/odoo/service/wsgi_server.py", line 87, in application_unproxied
result = odoo.http.root(environ, start_response)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 1335, in __call__
self.load_addons()
File "/usr/lib/python3/dist-packages/odoo/http.py", line 1345, in load_addons
for module in sorted(os.listdir(str(addons_path))):
PermissionError: [Errno 13] Permission denied: '/mnt/extra-addons' - - -
2022-09-15 07:43:18,119 1 INFO ? werkzeug: 172.21.0.1 - - [15/Sep/2022 07:43:18] "GET /favicon.ico HTTP/1.0" 500 - 0 0.000 0.002
2022-09-15 07:43:18,126 1 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/werkzeug/serving.py", line 323, in run_wsgi
execute(self.server.app)
File "/usr/lib/python3/dist-packages/werkzeug/serving.py", line 312, in execute
application_iter = app(environ, start_response)
File "/usr/lib/python3/dist-packages/odoo/service/server.py", line 482, in app
return self.app(e, s)
File "/usr/lib/python3/dist-packages/odoo/service/wsgi_server.py", line 112, in application
return application_unproxied(environ, start_response)
File "/usr/lib/python3/dist-packages/odoo/service/wsgi_server.py", line 87, in application_unproxied
result = odoo.http.root(environ, start_response)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 1336, in __call__
return self.dispatch(environ, start_response)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 1487, in dispatch
explicit_session = self.setup_session(httprequest)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 1367, in setup_session
session_gc(self.session_store)
File "/usr/lib/python3/dist-packages/odoo/tools/func.py", line 26, in __get__
value = self.fget(obj)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 1313, in session_store
path = odoo.tools.config.session_dir
File "/usr/lib/python3/dist-packages/odoo/tools/config.py", line 710, in session_dir
os.makedirs(d, 0o700)
File "/usr/lib/python3.9/os.py", line 225, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/var/lib/odoo/sessions' - - -
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the docker-compose.yml service definition and reproduce the container with user 1000:1000. Trace the reported failures through /usr/bin/odoo and odoo/cli/server.py, then verify that startup and requests work with the mounted /var/lib/odoo and /mnt/extra-addons paths without permission or UID lookup errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, docker-compose, python
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100