#112·textql

Cannot spawn a Docker container running as unprivileged user

Author: xi-aoCreated Feb 12, 2019Updated Mar 14, 2021

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?