qgis-docker icon indicating copy to clipboard operation
qgis-docker copied to clipboard

Run as non root user

Open timlinux opened this issue 3 years ago • 7 comments

It would be nice if the container ran as e.g. apache or other non-priveledged user....

timlinux avatar Sep 29 '21 10:09 timlinux

@timlinux part of it is already done, https://github.com/gem/oq-qgis-server/blob/master/start-xvfb-nginx.sh#L55 we'd need to add the USER directive to the dockerfile as well.

mbernasocchi avatar Oct 04 '21 15:10 mbernasocchi

@daniviga what do you think?

mbernasocchi avatar Oct 04 '21 15:10 mbernasocchi

You can run the FCGI process as different user, but not the entire container (e.g. passing -u). It should not be complex to make it user-friendly. At least I see that:

  • We need to put nginx running dirs (/var/lib/nginx, /var/log/nginx) on 777, since we can't predict the UID and GUID
  • We need to move away from port 80 since it cannot be bind by non-root users

However, does it worth the effort when the container runs perfectly fine in rootless mode? (Podman is your friend!) @vot4anto may have opinions here

daniviga avatar Oct 06 '21 17:10 daniviga

If someone (@timlinux?) wants to test it: https://github.com/daniviga/oq-qgis-server/tree/usermode

Please note that nginx is now exposed on 8080:

podman run --user 1000 --rm -ti -v $(pwd)/conf/qgis-server-nginx.conf:/etc/nginx/nginx.conf -v $(pwd)/test/data:/io/data -p 8010:8080 qgis

daniviga avatar Oct 06 '21 17:10 daniviga

Rootless is also available from docker: https://docs.docker.com/engine/security/rootless/ We can avoid to do modification if the container runs perfectly fine in rootless mode either with docker and podman. It is necessary to add the USER directive to Dockerfile? Because at gem we always use the container with docker-compose and set on the yaml file of the compose all the necessary environment

vot4anto avatar Oct 07 '21 07:10 vot4anto

@timlinux did you get the chance to try @daniviga's work?

mbernasocchi avatar Nov 09 '21 17:11 mbernasocchi

is this issue still relevant?

JakobMiksch avatar Apr 23 '24 09:04 JakobMiksch