-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues with temporary base_directory
permissions when running as root in Docker
#62
Comments
This does not necessarily requires a fix, but my question is: how could I use |
One last bit of evidence:
|
Thanks a lot for your help ! Using this repo current
Also:
|
From your doc, I thought that |
For that you'd have to follow master's readme. That version is not yet packaged though. And you'd need to pass both mysqld and mysqld_safe. That's just a wild guess with the master branch, I recall I had similar issues with directory access when adjusting code to MySQL >= 5.7.6 |
Sorry, I didn't understand what you meant there. |
I solved my issue with Now I have this error, using the current master branch of this repo:
|
See https://github.com/ClearcodeHQ/pytest-mysql#configuration master branch will eventually be tagged and released as v2.0.0, and it makes use of mysqld --initialize ( https://github.com/ClearcodeHQ/pytest-mysql/blob/master/src/pytest_mysql/executor.py#L63 ) to initialise mysql for tests, and mysqld_safe to run the server. While the 1.1.1 version uses now deprecated/removed mysql_install_db |
The command executed was
|
Thanks for you answer. Seems like
|
|
does mysql_install_db allow for switching user? OR can you use docker with other user? Alternatively, does it work if you try to run it locally without docker? |
Sorry, I cannot invest more time in trying to make this work right now. Thanks a lot for your help ! For others hitting the same issue, I would recommend to follow @fizyk suggestion to run your tests in Docker under another user. Feel free to close this issue if you want. |
pytest-mysql tests succeed in Docker when running as a non-root user; my Dockerfile:
Before Docker, it was very unusual to run such tests as root: I think it's ok to declare running pytest-mysql as root as unsupported and close this issue (there are others for running with MariaDB). |
Okay, I'll close it after we'll land a readme section on how to run it in docker. |
Hi @fizyk, I know this thread is old but I want to mention that another way to run pytest-mysql in Docker is very simple, just add
That's all and we can run our app as root (maybe other processes need root permission). It is easy and useful, so I think it's worth it to mention in README. |
What action do you want to perform
Simply use
pytest-mysql
, but in a Docker containerWhat are the results
Because the user executing
py.test
is root, themysqld
process does not have the rights to read/write in the temporary directory created.Specifically, this
base_directory
is created infactories/process.py
. Becausepy.test
tmpdir_factory
relies on Python nativetempfile.mkdtemp
, the following extract from the doc applies:This explains the errors I get:
And in
/tmp/mysql-server.31589.log
:What are the expected results
No errors
The text was updated successfully, but these errors were encountered: