Prevent Gitea docker on Windows from running with OpenSSH private key directory mounted to a shared host directory (volume) #8824

Closed
opened 2025-11-02 08:20:01 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @wxiaoguang on GitHub (Apr 13, 2022).

Due to the limitation of Docker on Windows: https://docs.docker.com/desktop/faqs/windowsfaqs/#can-i-change-permissions-on-shared-volumes-for-container-specific-deployment-requirements , the files in the shared host directory (volume) can not be operated by chmod. 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".

However, OpenSSH requires that the private keys should be mode 0600 (for security reason).

Then the problem comes: if users use a Gitea Docker (root/OpenSSH) + Windows + Host Directory Volume, then they will meet a bug: OpenSSH can not generate private keys correctly and keeps restarting.

There are some works should be done:

  1. Update document to describe such problem
  2. Tell users to use Docker.rootless on Windows, or do not mount the data directory to host directory when using Docker (root) image
  3. Add a startup check in the Docker (root) image to detect whether chmod works correctly for the OpenSSH private key directory

Related issue:

Originally created by @wxiaoguang on GitHub (Apr 13, 2022). Due to the limitation of Docker on Windows: https://docs.docker.com/desktop/faqs/windowsfaqs/#can-i-change-permissions-on-shared-volumes-for-container-specific-deployment-requirements , the files in the shared host directory (volume) can not be operated by `chmod`. 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". However, OpenSSH requires that the private keys should be mode 0600 (for security reason). Then the problem comes: if users use a Gitea Docker (root/OpenSSH) + Windows + Host Directory Volume, then they will meet a bug: OpenSSH can not generate private keys correctly and keeps restarting. There are some works should be done: 1. Update document to describe such problem 2. Tell users to use Docker.rootless on Windows, or do not mount the data directory to host directory when using Docker (root) image 3. Add a startup check in the Docker (root) image to detect whether `chmod` works correctly for the OpenSSH private key directory Related issue: * https://github.com/go-gitea/gitea/issues/14662
GiteaMirror added the topic/distributiontype/docstype/bugissue/workaround labels 2025-11-02 08:20:01 -06:00
Author
Owner

@wxiaoguang commented on GitHub (Dec 13, 2022):

No more feedbacks. It seems that Docker WSL2 backend works better now.

@wxiaoguang commented on GitHub (Dec 13, 2022): No more feedbacks. It seems that Docker WSL2 backend works better now.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#8824