Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Letting the container run with non-root privilegues creates ? directory #11

Closed
manuel-wagesreither opened this issue Aug 4, 2022 · 7 comments · Fixed by #12
Closed

Comments

@manuel-wagesreither
Copy link

manuel-wagesreither commented Aug 4, 2022

Hi miy4,

thanks for creating this project, we're using it to create deployment diagrams of our CI pipeline.

We noticed when letting the container run with normal privilegues, that is, like so

$ docker run -v ${PWD}:/work -w /work --user $(id -u):$(id -g) --rm [PLANTUML OPTIONS and ARGUMENTS]

it creates an empty ? directory next to the PNG.

Just wanted to make you aware of this, thought you might be interested in hearing about this.

Best regards,
Manuel

@miy4
Copy link
Owner

miy4 commented Aug 5, 2022

Hi manuel, thanks for the report!

I was able to reproduce in my environment. With --user option, you've passed the UID and GID to the Docker container, but Alpine Linux on the container side doesn't know these IDs, so the Java runtime looks confused.
The ? directory contains a file named fcinfo.*.properties which is dumped by the Java runtime.

$ ls -AR \?
'?':
.java

'?/.java':
fonts

'?/.java/fonts':
1.8.0_282

'?/.java/fonts/1.8.0_282':
fcinfo-1-bdf28f30a749-Linux-5.10.102.1-microsoft-standard-WSL2-en.properties

@miy4
Copy link
Owner

miy4 commented Aug 5, 2022

I noticed that without the --user, the owner of the PNG files generated by PlantUML is root. I guess this is why you use --user. (I noticed just now. It's a shame)

@manuel-wagesreither
Copy link
Author

I noticed that without the --user, the owner of the PNG files generated by PlantUML is root. I guess this is why you use --user

Exactly. In the Debian container images I build, I usually don't use --user. Instead, I provide the UID and GID as environment variable and set a custom entrypoint.sh to create an user with the right UID/GID at container runtime. The very last thing entprypoint.sh does is to drop the root privilegues using gosu and switch into the just created user.

https://gitlab.com/manuel_wagesreither/bora-proj/-/blob/master/docker/entrypoint.sh#L9

@manuel-wagesreither
Copy link
Author

I forked your repo and tried to add the solution discussed above. Unfortunately building the docker image fails with gosu not being available. Indeed, it seems to be available in testing only.

@miy4
Copy link
Owner

miy4 commented Aug 8, 2022

I am now preparing to address this issue, so this is very helpful. Thank you :)

Unfortunately building the docker image fails with gosu not being available. Indeed, it seems to be available in testing only.

su-exec does the same thing and is available in the main repos. It looks nice.

@miy4
Copy link
Owner

miy4 commented Aug 8, 2022

I made a pull-req. Any comments are appreciated :)

You can explicitly pass UID and GID using environment variables.
And, I added an implicit approach. If you don't use env vars, PlantUML generates the files to have the same UID and GID as the owner of the working directory given by -w, --workdir.

miy4 added a commit that referenced this issue Aug 15, 2022
Avoid having ownership issue when using Docker Volumes (fix #11)
@miy4 miy4 closed this as completed in #12 Aug 15, 2022
@miy4
Copy link
Owner

miy4 commented Aug 16, 2022

If you want to discuss this further, feel free to reopen it. Thanks for your contribution!

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

Successfully merging a pull request may close this issue.

2 participants