Open looztra opened 6 years ago
Please keep your language professional. I have edited your message.
I see your problem, however I'm not a fan of the proposed solution as it makes the project deviates from the use of a standard well-known image, which makes on-boarding more difficult. I think the underlying issue is that the container is writing files to the host file system. Maybe we should not have it to that. Maybe the PDFs should be produced on stdout? Or maybe the container should server the PDFs over HTTP and the outside world would need to download them. What do you think?
Please keep your language professional. I have edited your message.
What? Not sure to appreciate your judgement if I'm professional or not in my comment to be honnest
My point of view: ease the life of users as much as possible even if it means that the life of maintainers may be more difficult.
library/node
, then I'm not surprised, while if I see mkenney/npm
, I wonder why that is.run.sh
, not the users, wouldn't it?I prefer to add a comment explaining why we use mkenney/npm
over library/node
and keep the same logic in run.sh
(we will just need to change one of the volume mounts I think)
rather than
keeping library/node
and change the behaviour of grunt pdf
and grunt generateCahierExercice
and the logic in run.sh
Maybe we could ask what other contributors think about it?
Sure, ping anyone you like.
dear @jlandure @zigarn @gmembre-zenika @FBerthelot could you tell us what you think about the solutions proposed by @hgwood and myself?
I prefer the way @looztra want to change the behaviour. Let me explain :
libray/node
will change to adopt this security mesure but in the mean time, we can go further by using another image. A simple comment to explain should do it.run.sh
in order to handle pdf stream to stdout
will be difficult task, it'll involved being able to split the file received at the correct position as there are multiple files and pdf produced : slides in HTML / PDF and student book. => Good luck with it without installing any other tool on the host.@gmembre-zenika if stdout would be chosen then there would be one command by generated file (run.sh pdf-slides
, run.sh pdf-labs
, ...).
Are there any official images that adopt the non-root practice?
@looztra I've changed my mind and I encourage you to go forward with your change, for two reasons:
run.sh
, which is duplicated in every depending project and hard to keep properly updated and versioned, yours puts it in the Dockerfile of the framework, which is centralized and properly versionedMy question from my last comment still stands though, for my own culture. :)
Another way to satisfy the non root : why not use the -u <id>
(doc) option while running the official image library/node
?
Taken care must taken while choosing the uid, is must match the current user but it simple to get : id -u
on linux.
@looztra : any suggestions ?
@gmembre-zenika : the -u <id>
doesn't seem to work with the nodejs image. I never tried to find out why to be honest.
@hgwood: the answer is related to my reply to @gmembre-zenika : you can use the mvn docker image with the -u
option (that specifies the user used by the docker image at runtime) with no problem, but that does not work with node. The behaviour is related to the pid 1
process in the docker image not to the way the image is built it seems.
Indeed, that's better than running as root.
The mkenney/npm
goes further and
... executes the specified command as a user who's uid and gid matches those properties on that directory
It means that it is not limited to run with a uid/groupid of 1000/1000
I will make some experiments and play with both solutions...and report my findings :)
The base image for the docker image uses
library/node
which is suboptimal because every directory created by this image (like thePDF
one for example) will be owned by root on the docker host.sudo rm -rf PDF
to get it cleaned under linux is cumbersomeI propose that we either use mkenney/npm as the base image or that we get inspired from it to build the fwk docker image. This image automagically switches to the current uid/gid inside the running container, hence every directory/file created by node inside the container stick to the user that created the directory on the docker host.
First option : use it as the base image. Problem: the image uses
/src
inside the container to detect the target uid/gid, so we will need to adjustrun.sh
to also mount a host dir on/src
in the containerSecond option : mimic the behaviour of the mkenney/npm image and copy and adjust the run-as-user script to, for instance, use one of the already mounted dirs
For the moment, I'd favour the first option because I think that adjusting
run.sh
will require less efforts than having to sync our fork of therun-as-user
with the original one.What's your point of view regarding this?