Skip to content
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

Cannot spawn a Docker container running as unprivileged user #112

Open
xi-ao opened this issue Feb 12, 2019 · 1 comment
Open

Cannot spawn a Docker container running as unprivileged user #112

xi-ao opened this issue Feb 12, 2019 · 1 comment

Comments

@xi-ao
Copy link

xi-ao commented Feb 12, 2019

The advice of creating such an alias in the README is really good and works well:

alias textql='docker run --rm -it -v $(pwd):/tmp textql '

but the problem with it is that it runs textql as root and so the output files are created with that user.

Ideally, the solution would be to use this command instead:

alias textql='docker run --rm --user $(id -u):$(id -g) -it -v $(pwd):/tmp textql '

which works fine when called like this

textql
(...usage shown...)

but not when an actual SQL processing is requested:

textql -sql 'SELECT * FROM groups LIMIT 2' groups.csv
2019/02/12 07:26:44 user: unknown userid 1000

Is there a way to fix that?

@supriya
Copy link

supriya commented Mar 14, 2021

@xi-ao Perhaps the change can be as simple as adding a new user in the dockerfile like
RUN useradd app
USER app

and then you can run docker run --rm -u app:app -it -v $(pwd):/tmp textql -header -sql "select count() from test" test.csv

Let me if this solution looks good to you. I can open a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants