-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Gitea Docker in Windows shouldn't mount the ssh key directory to shared host directory, chmod doesn't work #14662
Comments
I suspect that the situation here is related to your docker install The key should be being recreated like that constantly and it suggests that your docker is constantly being brought up and shut down. Logs would have been helpful and probably would have shown that the docker was constantly been created and recreated. |
I do not fully understand how my "docker is being constantly created and recreated". Also I should note that I have ~20+ containers residing in the same docker instance and none are misbehaving like this. |
I've checked the logs and the issue is with permissions:
Any ideas how to fix/workaround this? I checked and I always did have SSH disabled (as I didn't plan to use it) with Please check timestamps in the screenshot to see that this is happening during container running (not restarting). Recreation of the SSH keys happens hundreds times each second in some loop and it will eat up SSD. |
Maybe the check should be altered to halt on exception regarding the wrong permission? Or continue and only log a warning? Or could we get an option to set desired access rights? Maybe the 755 is exactly what I want. Or maybe it just should not even touch the keys if I have disabled SSH in the settings, but this feels like hiding a problem. |
OK so the root cause of this problem is your docker drive mounting configuration. OpenSSH enforces this access rule by immediately dying. Docker/S6 will then, by default, just restart the dying service - and that is what your docker appears to be doing. Unfortunately our container is rather dumb and expects you to notice that it is repeatedly doing so - by paying attention to your logs. We never expected that anyone would experience this - as OpenSSH's requirements for permissions for its files are fairly well known, and googling should have revealed the issue fairly rapidly. So - if you really have no need for OpenSSH how do you disable it and prevent it starting? Well, the Gitea setting You will either have to edit the docker to stop OpenSSH from being started, i.e. remove /etc/s6/openssh from your dockers or adjust your docker drive configuration to fix this. PRs are welcome to provide configuration options to disable the OpenSSH server - however, when 1.14 is released there will be a rootless docker option available that does not use OpenSSH and in that case the DISABLE_SSH would disable the SSH service. Whilst I am sorry that this docker instance appears to have damaged your SSD - you should have been watching your logs. Googling the logs would have revealed the problem immediately. However, clearly there are some underlying issues here:
Would you be able to tell me if it was docker that was cycling the service or was it S6 inside our container? If it was the external docker server then I'm not sure what we can do. If it was S6 inside our container then we at least have some chance to provide something to prevent this happening again. |
Thanks for long and extensive answer. First of all I would like to clarify that the issue is not THE ssd, issue is that it could be potentially doing harm to someone else with similar setup. That SSD was an old one anyways and I have found workaround by having the keys inside the virtual machine by using "-v /tmp/gitea/ssh:/data/ssh", where they stay inside Linux and permissions are written correctly (I assume). Root cause is my docker drive mounting configuration, that is true, but the issue here is that it can not be done any differently in Docker for Windows. Windows mangles the permissions requested by the guest linux OS. I don't have WSL2 available on that machine, which could fix that (?). My docker is not restarting the container - container is running well. Inside the container some loop keeps checking and recreating the keys. I think having container actually halt because of seemingly so significant security issue would be a better option. Docker would try to restart the container, but it would halt again. This cycling of container state is much easier to notice, even without having to change log level and look into logs. I understand that the loop is trying to silently fix permissions issue for me, but it is failing to do so and actually it is leaving me with unsecured keys. I am not sure how to help with diagnosing if it was the S6, as I am not a Linux guy. Gitea container was not being restarted, I was actually using it actively via the web UI without any issues. |
Within your docker containers remove /etc/s6/openssh |
rm -rf /etc/s6/openssh results in: I reverted back to having ssh keys in tmp, because after next autoupdate new image will restore containers data. |
Mention in webpack PR is completely random and this issue has not been actually touched. This issue might be still creating enormous write loads on people's ssds, yet it was just dismissed. |
The webpack mention is unrelated spam, and this was closed due to it being upstream with opensshd. We have a rootless image now that can be used which doesn't use opensshd at all. |
openssh requires that some files must have mode 0600, if your file system doesn't support file mode, then you might be stuck in the openssh key generation. I am not sure how docker volume works in windows, however it seems incorrect that you mount the ssh directory separately outside docker. maybe the direction of this issue is to try to figure out how docker + gitea + openssh + windows volume work together, and check whether the file mode is correct. update: it seems that docker + windows + volume can not do chmod: https://docs.docker.com/desktop/faqs/#can-i-change-permissions-on-shared-volumes-for-container-specific-deployment-requirements . the docker's answer is : "you need to either use non-host-mounted volumes or find a way to make the applications work with the default file permissions". so, the conclusion is: you shouldn't mount the openssh private key directory to host directory in windows. |
So now there is no need to separately mount ssh keys at all? I mean the |
I came to this conclusion in february. However as I dont know what I dont know I could not have known there are some ssh keys being stored in the given volume. Only thing that saved me was monitoring that was crying about falling wear level count. |
I created a new issue for this problem: |
[x]
):Description
I installed gitea on 2020-01-12 in docker for windows with a command docker run --name gitea -v C:/Docker/Gitea:/data:delegated --network=bridgenet -d gitea/gitea:latest
Since then I have noticed extraordinarily fast decline in SSD wear, which is monitored. On 2020-02-06 I have diagnosed culprit (gitea) and removed the container. Wear of the SSD stopped.
I now tried running gitea while storing its ssh keys somewhere in virtual machine of docker for windows - I don't care about those and obviously those will get generated anyway - docker run --name gitea -v C:/Docker/Gitea:/data:delegated -v /tmp/gitea/ssh:/data/ssh --network=bridgenet -d gitea/gitea:latest
It seems the extreme accessing of the host drive stopped.
Screenshots
Notice extreme lowering of wear level during running gitea:
Thousands of accesses to ssh files of gitea from docker:
The text was updated successfully, but these errors were encountered: