Description
Whenever I restart my Forgejo container, all my repositories are deleted and my user settings are gone. I can see in the docker logs that this seems to be a rights issue. The Dockerfile tries at the beginning to chown/chmod folders in the remote folder, which does not work, however then proceeds to create folders as usual, independently whether or not folders are present already.
I don't really understand what's going on. So my questions:
- Why is the container force-overwriting the folders when restarting?
- If it's a rights issue - why is the ssh folder not immediately created with the correct rights?
- Coming to think of it, while it's convenient to own the file for user rights, why do I need to own the files and folders at all as long as I can read and write them? Checking
app.ini shows me
daniel@xxx:/Repositories/gitea/conf$ ls -lah
total 4.0K
drwxrwxrwx 1 admin users 14 Oct 9 20:35 .
drwxr-xr-x 1 admin users 14 Oct 9 20:35 ..
-rwxrwxrwx 1 admin users 1.1K Oct 9 20:35 app.ini
So the default file does have read and write access already, I'm not sure what more it would need
Forgejo Version
1.20
Can you reproduce the bug on Forgejo Next?
No
Logs
NFS setting on file server (/etc/export)
/Repositories *(rw,async,no_wdelay,crossmnt,insecure,all_squash,insecure_locks,sec=sys,anonuid=xxx,anongid=yyy)
Starting the service on server2, which is not the file server but the application server:
daniel@server2:~ $ docker compose -f Software/forgejo.yaml up
[+] Running 2/2
✔ Network software_forgejo Created 0.2s
✔ Container forgejo Created 0.3s
Attaching to forgejo
forgejo | Generating /data/ssh/ssh_host_ed25519_key...
forgejo | Generating /data/ssh/ssh_host_rsa_key...
forgejo | chown: /data/gitea/conf/app.ini: Operation not permitted
forgejo | chown: /data/gitea/conf/app.ini: Operation not permitted
forgejo | chown: /data/gitea/conf: Operation not permitted
forgejo | chown: /data/gitea/conf: Operation not permitted
forgejo | chown: /data/gitea/log: Operation not permitted
forgejo | chown: /data/gitea/log: Operation not permitted
forgejo | chown: /data/gitea: Operation not permitted
forgejo | chown: /data/gitea: Operation not permitted
forgejo | Generating /data/ssh/ssh_host_ecdsa_key...
forgejo | chown: /data/ssh/ssh_host_ecdsa_key: Operation not permitted
forgejo | chown: /data/ssh/ssh_host_ecdsa_key.pub: Operation not permitted
forgejo | chown: /data/ssh/ssh_host_ed25519_key: Operation not permitted
forgejo | chown: /data/ssh/ssh_host_ed25519_key.pub: Operation not permitted
forgejo | chown: /data/ssh/ssh_host_rsa_key: Operation not permitted
forgejo | chown: /data/ssh/ssh_host_rsa_key.pub: Operation not permitted
forgejo | Server listening on :: port 22.
forgejo | Server listening on 0.0.0.0 port 22.
forgejo | chown: /data/git/.ssh/environment: Operation not permitted
forgejo | chown: /data/git/.ssh: Operation not permitted
forgejo | chown: /data/git/.ssh: Operation not permitted
forgejo | chown: /data/git: Operation not permitted
forgejo | chown: /data/git: Operation not permitted
forgejo | 2023年10月09日 18:35:14 ...nvironment-to-ini.go:99:runEnvironmentToIni() [I] Settings saved to: "/data/gitea/conf/app.ini"
forgejo | 2023年10月09日 18:35:14 cmd/web.go:223:runWeb() [I] Starting Gitea on PID: 15
forgejo | 2023年10月09日 18:35:14 cmd/web.go:106:serveInstall() [I] Gitea version: 1.20.4+0 built with GNU Make 4.4.1, go1.20.8 : bindata, timetzdata, sqlite, sqlite_unlock_notify
forgejo | 2023年10月09日 18:35:14 cmd/web.go:107:serveInstall() [I] App path: /usr/local/bin/gitea
forgejo | 2023年10月09日 18:35:14 cmd/web.go:108:serveInstall() [I] Work path: /data/gitea
forgejo | 2023年10月09日 18:35:14 cmd/web.go:109:serveInstall() [I] Custom path: /data/gitea
forgejo | 2023年10月09日 18:35:14 cmd/web.go:110:serveInstall() [I] Config file: /data/gitea/conf/app.ini
forgejo | 2023年10月09日 18:35:14 cmd/web.go:111:serveInstall() [I] Prepare to run install page
forgejo | 2023年10月09日 18:35:15 cmd/web.go:285:listen() [I] Listen: http://0.0.0.0:3000
forgejo | 2023年10月09日 18:35:15 cmd/web.go:289:listen() [I] AppURL(ROOT_URL): http://localhost:3000/
forgejo | 2023年10月09日 18:35:15 ...s/graceful/server.go:62:NewServer() [I] Starting new Web server: tcp:0.0.0.0:3000 on PID: 15
Folders created by this on the file server (1):
daniel@xxx:/Repositories$ ls -lah
total 4.0K
drwxrwxrwx+ 1 root root 90 Oct 9 20:35 .
drwxr-xr-x 1 root root 598 Oct 7 01:10 ..
drwxr-xr-x 1 admin users 8 Oct 9 20:35 git
drwxr-xr-x 1 admin users 14 Oct 9 20:35 gitea
drwxrwxrwx+ 1 root root 44 Oct 9 19:54 '#recycle'
drwx------ 1 admin users 240 Oct 9 20:35 ssh
Manually changing access rights on the file server
daniel@xxx:/Repositories$ sudo chmod a+rw -R ssh git gitea
Password:
daniel@xxx:/Repositories$ ls -lah
total 4.0K
drwxrwxrwx+ 1 root root 90 Oct 9 20:35 .
drwxr-xr-x 1 root root 598 Oct 7 01:10 ..
drwxrwxrwx 1 admin users 8 Oct 9 20:35 git
drwxrwxrwx 1 admin users 14 Oct 9 20:35 gitea
drwxrwxrwx+ 1 root root 44 Oct 9 19:54 '#recycle'
drwxrw-rw- 1 admin users 240 Oct 9 20:35 ssh
Then(!) restarting the service, leading to the same situation as in (1):
forgejo | 2023年10月09日 18:35:15 ...s/graceful/server.go:62:NewServer() [I] Starting new Web server: tcp:0.0.0.0:3000 on PID: 15
^CGracefully stopping... (press Ctrl+C again to force)
Aborting on container exit...
[+] Stopping 1/1
✔ Container forgejo Stopped 1.6s
canceled
daniel@server2:~ $ docker compose -f Software/forgejo.yaml up
[+] Running 1/0
✔ Container forgejo Created 0.0s
Attaching to forgejo
forgejo | chown: /data/ssh/ssh_host_ecdsa_key: Operation not permitted
forgejo | chown: /data/ssh/ssh_host_ecdsa_key.pub: Operation not permitted
forgejo | chown: /data/ssh/ssh_host_ed25519_key: Operation not permitted
forgejo | chown: /data/ssh/ssh_host_ed25519_key.pub: Operation not permitted
forgejo | chown: /data/gitea/conf/app.ini: Operation not permitted
forgejo | chown: /data/ssh/ssh_host_rsa_key: Operation not permitted
forgejo | chown: /data/gitea/conf: Operation not permitted
forgejo | chown: /data/gitea/conf: Operation not permitted
forgejo | chown: /data/ssh/ssh_host_rsa_key.pub: Operation not permitted
forgejo | chown: /data/gitea/log: Operation not permitted
forgejo | chown: /data/gitea/log: Operation not permitted
forgejo | chown: /data/gitea: Operation not permitted
forgejo | chown: /data/gitea: Operation not permitted
forgejo | chown: /data/git/.ssh/environment: Operation not permitted
forgejo | chown: /data/git/.ssh: Operation not permitted
forgejo | chown: /data/git/.ssh: Operation not permitted
forgejo | chown: /data/git: Operation not permitted
forgejo | chown: /data/git: Operation not permitted
forgejo | Server listening on :: port 22.
forgejo | Server listening on 0.0.0.0 port 22.
forgejo | 2023年10月09日 18:40:25 cmd/web.go:223:runWeb() [I] Starting Gitea on PID: 16
forgejo | 2023年10月09日 18:40:25 cmd/web.go:106:serveInstall() [I] Gitea version: 1.20.4+0 built with GNU Make 4.4.1, go1.20.8 : bindata, timetzdata, sqlite, sqlite_unlock_notify
forgejo | 2023年10月09日 18:40:25 cmd/web.go:107:serveInstall() [I] App path: /usr/local/bin/gitea
forgejo | 2023年10月09日 18:40:25 cmd/web.go:108:serveInstall() [I] Work path: /data/gitea
forgejo | 2023年10月09日 18:40:25 cmd/web.go:109:serveInstall() [I] Custom path: /data/gitea
forgejo | 2023年10月09日 18:40:25 cmd/web.go:110:serveInstall() [I] Config file: /data/gitea/conf/app.ini
forgejo | 2023年10月09日 18:40:25 cmd/web.go:111:serveInstall() [I] Prepare to run install page
forgejo | 2023年10月09日 18:40:26 cmd/web.go:285:listen() [I] Listen: http://0.0.0.0:3000
forgejo | 2023年10月09日 18:40:26 cmd/web.go:289:listen() [I] AppURL(ROOT_URL): http://localhost:3000/
forgejo | 2023年10月09日 18:40:26 ...s/graceful/server.go:62:NewServer() [I] Starting new Web server: tcp:0.0.0.0:3000 on PID: 16
Screenshots
No response
Git Version
No response
Operating System
Raspberry Pi OS (Bookworm)
How are you running Forgejo?
I'm running Forgejo on a Rasperry Pi 4 via Docker and have mounted the docker volume on a NFS share.
Docker file:
daniel@server2:~ $ cat Software/forgejo.yaml
version: "3"
networks:
forgejo:
external: false
services:
server:
image: codeberg.org/forgejo/forgejo:1.20
container_name: forgejo
environment:
- USER_UID=1000
- USER_GID=1000
- FORGEJO__database__DB_TYPE=postgres
- FORGEJO__database__HOST=xxx:yyy
- FORGEJO__database__NAME=forgejo
- FORGEJO__database__USER=forgejo
- FORGEJO__database__PASSWD=forgejo
restart: always
networks:
- forgejo
volumes:
- /mnt/repositories:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "222:22"
Database
PostgreSQL
### Description
Whenever I restart my Forgejo container, all my repositories are deleted and my user settings are gone. I can see in the docker logs that this seems to be a rights issue. The Dockerfile tries at the beginning to `chown/chmod` folders in the remote folder, which does not work, however then proceeds to create folders as usual, independently whether or not folders are present already.
I don't really understand what's going on. So my questions:
1. Why is the container force-overwriting the folders when restarting?
2. If it's a rights issue - why is the ssh folder not immediately created with the correct rights?
3. Coming to think of it, while it's convenient to own the file for user rights, why do I need to own the files and folders at all as long as I can read and write them? Checking `app.ini` shows me
```bash
daniel@xxx:/Repositories/gitea/conf$ ls -lah
total 4.0K
drwxrwxrwx 1 admin users 14 Oct 9 20:35 .
drwxr-xr-x 1 admin users 14 Oct 9 20:35 ..
-rwxrwxrwx 1 admin users 1.1K Oct 9 20:35 app.ini
```
So the default file does have read and write access already, I'm not sure what more it would need
### Forgejo Version
1.20
### Can you reproduce the bug on Forgejo Next?
No
### Logs
NFS setting on file server (`/etc/export`)
```bash
/Repositories *(rw,async,no_wdelay,crossmnt,insecure,all_squash,insecure_locks,sec=sys,anonuid=xxx,anongid=yyy)
```
Starting the service on `server2`, which is not the file server but the application server:
```bash
daniel@server2:~ $ docker compose -f Software/forgejo.yaml up
[+] Running 2/2
✔ Network software_forgejo Created 0.2s
✔ Container forgejo Created 0.3s
Attaching to forgejo
forgejo | Generating /data/ssh/ssh_host_ed25519_key...
forgejo | Generating /data/ssh/ssh_host_rsa_key...
forgejo | chown: /data/gitea/conf/app.ini: Operation not permitted
forgejo | chown: /data/gitea/conf/app.ini: Operation not permitted
forgejo | chown: /data/gitea/conf: Operation not permitted
forgejo | chown: /data/gitea/conf: Operation not permitted
forgejo | chown: /data/gitea/log: Operation not permitted
forgejo | chown: /data/gitea/log: Operation not permitted
forgejo | chown: /data/gitea: Operation not permitted
forgejo | chown: /data/gitea: Operation not permitted
forgejo | Generating /data/ssh/ssh_host_ecdsa_key...
forgejo | chown: /data/ssh/ssh_host_ecdsa_key: Operation not permitted
forgejo | chown: /data/ssh/ssh_host_ecdsa_key.pub: Operation not permitted
forgejo | chown: /data/ssh/ssh_host_ed25519_key: Operation not permitted
forgejo | chown: /data/ssh/ssh_host_ed25519_key.pub: Operation not permitted
forgejo | chown: /data/ssh/ssh_host_rsa_key: Operation not permitted
forgejo | chown: /data/ssh/ssh_host_rsa_key.pub: Operation not permitted
forgejo | Server listening on :: port 22.
forgejo | Server listening on 0.0.0.0 port 22.
forgejo | chown: /data/git/.ssh/environment: Operation not permitted
forgejo | chown: /data/git/.ssh: Operation not permitted
forgejo | chown: /data/git/.ssh: Operation not permitted
forgejo | chown: /data/git: Operation not permitted
forgejo | chown: /data/git: Operation not permitted
forgejo | 2023年10月09日 18:35:14 ...nvironment-to-ini.go:99:runEnvironmentToIni() [I] Settings saved to: "/data/gitea/conf/app.ini"
forgejo | 2023年10月09日 18:35:14 cmd/web.go:223:runWeb() [I] Starting Gitea on PID: 15
forgejo | 2023年10月09日 18:35:14 cmd/web.go:106:serveInstall() [I] Gitea version: 1.20.4+0 built with GNU Make 4.4.1, go1.20.8 : bindata, timetzdata, sqlite, sqlite_unlock_notify
forgejo | 2023年10月09日 18:35:14 cmd/web.go:107:serveInstall() [I] App path: /usr/local/bin/gitea
forgejo | 2023年10月09日 18:35:14 cmd/web.go:108:serveInstall() [I] Work path: /data/gitea
forgejo | 2023年10月09日 18:35:14 cmd/web.go:109:serveInstall() [I] Custom path: /data/gitea
forgejo | 2023年10月09日 18:35:14 cmd/web.go:110:serveInstall() [I] Config file: /data/gitea/conf/app.ini
forgejo | 2023年10月09日 18:35:14 cmd/web.go:111:serveInstall() [I] Prepare to run install page
forgejo | 2023年10月09日 18:35:15 cmd/web.go:285:listen() [I] Listen: http://0.0.0.0:3000
forgejo | 2023年10月09日 18:35:15 cmd/web.go:289:listen() [I] AppURL(ROOT_URL): http://localhost:3000/
forgejo | 2023年10月09日 18:35:15 ...s/graceful/server.go:62:NewServer() [I] Starting new Web server: tcp:0.0.0.0:3000 on PID: 15
```
Folders created by this on the file server (1):
```bash
daniel@xxx:/Repositories$ ls -lah
total 4.0K
drwxrwxrwx+ 1 root root 90 Oct 9 20:35 .
drwxr-xr-x 1 root root 598 Oct 7 01:10 ..
drwxr-xr-x 1 admin users 8 Oct 9 20:35 git
drwxr-xr-x 1 admin users 14 Oct 9 20:35 gitea
drwxrwxrwx+ 1 root root 44 Oct 9 19:54 '#recycle'
drwx------ 1 admin users 240 Oct 9 20:35 ssh
```
Manually changing access rights on the file server
```bash
daniel@xxx:/Repositories$ sudo chmod a+rw -R ssh git gitea
Password:
daniel@xxx:/Repositories$ ls -lah
total 4.0K
drwxrwxrwx+ 1 root root 90 Oct 9 20:35 .
drwxr-xr-x 1 root root 598 Oct 7 01:10 ..
drwxrwxrwx 1 admin users 8 Oct 9 20:35 git
drwxrwxrwx 1 admin users 14 Oct 9 20:35 gitea
drwxrwxrwx+ 1 root root 44 Oct 9 19:54 '#recycle'
drwxrw-rw- 1 admin users 240 Oct 9 20:35 ssh
```
Then(!) restarting the service, leading to the same situation as in (1):
```bash
forgejo | 2023年10月09日 18:35:15 ...s/graceful/server.go:62:NewServer() [I] Starting new Web server: tcp:0.0.0.0:3000 on PID: 15
^CGracefully stopping... (press Ctrl+C again to force)
Aborting on container exit...
[+] Stopping 1/1
✔ Container forgejo Stopped 1.6s
canceled
daniel@server2:~ $ docker compose -f Software/forgejo.yaml up
[+] Running 1/0
✔ Container forgejo Created 0.0s
Attaching to forgejo
forgejo | chown: /data/ssh/ssh_host_ecdsa_key: Operation not permitted
forgejo | chown: /data/ssh/ssh_host_ecdsa_key.pub: Operation not permitted
forgejo | chown: /data/ssh/ssh_host_ed25519_key: Operation not permitted
forgejo | chown: /data/ssh/ssh_host_ed25519_key.pub: Operation not permitted
forgejo | chown: /data/gitea/conf/app.ini: Operation not permitted
forgejo | chown: /data/ssh/ssh_host_rsa_key: Operation not permitted
forgejo | chown: /data/gitea/conf: Operation not permitted
forgejo | chown: /data/gitea/conf: Operation not permitted
forgejo | chown: /data/ssh/ssh_host_rsa_key.pub: Operation not permitted
forgejo | chown: /data/gitea/log: Operation not permitted
forgejo | chown: /data/gitea/log: Operation not permitted
forgejo | chown: /data/gitea: Operation not permitted
forgejo | chown: /data/gitea: Operation not permitted
forgejo | chown: /data/git/.ssh/environment: Operation not permitted
forgejo | chown: /data/git/.ssh: Operation not permitted
forgejo | chown: /data/git/.ssh: Operation not permitted
forgejo | chown: /data/git: Operation not permitted
forgejo | chown: /data/git: Operation not permitted
forgejo | Server listening on :: port 22.
forgejo | Server listening on 0.0.0.0 port 22.
forgejo | 2023年10月09日 18:40:25 cmd/web.go:223:runWeb() [I] Starting Gitea on PID: 16
forgejo | 2023年10月09日 18:40:25 cmd/web.go:106:serveInstall() [I] Gitea version: 1.20.4+0 built with GNU Make 4.4.1, go1.20.8 : bindata, timetzdata, sqlite, sqlite_unlock_notify
forgejo | 2023年10月09日 18:40:25 cmd/web.go:107:serveInstall() [I] App path: /usr/local/bin/gitea
forgejo | 2023年10月09日 18:40:25 cmd/web.go:108:serveInstall() [I] Work path: /data/gitea
forgejo | 2023年10月09日 18:40:25 cmd/web.go:109:serveInstall() [I] Custom path: /data/gitea
forgejo | 2023年10月09日 18:40:25 cmd/web.go:110:serveInstall() [I] Config file: /data/gitea/conf/app.ini
forgejo | 2023年10月09日 18:40:25 cmd/web.go:111:serveInstall() [I] Prepare to run install page
forgejo | 2023年10月09日 18:40:26 cmd/web.go:285:listen() [I] Listen: http://0.0.0.0:3000
forgejo | 2023年10月09日 18:40:26 cmd/web.go:289:listen() [I] AppURL(ROOT_URL): http://localhost:3000/
forgejo | 2023年10月09日 18:40:26 ...s/graceful/server.go:62:NewServer() [I] Starting new Web server: tcp:0.0.0.0:3000 on PID: 16
```
### Screenshots
_No response_
### Git Version
_No response_
### Operating System
Raspberry Pi OS (Bookworm)
### How are you running Forgejo?
I'm running Forgejo on a Rasperry Pi 4 via Docker and have mounted the docker volume on a NFS share.
Docker file:
```bash
daniel@server2:~ $ cat Software/forgejo.yaml
version: "3"
networks:
forgejo:
external: false
services:
server:
image: codeberg.org/forgejo/forgejo:1.20
container_name: forgejo
environment:
- USER_UID=1000
- USER_GID=1000
- FORGEJO__database__DB_TYPE=postgres
- FORGEJO__database__HOST=xxx:yyy
- FORGEJO__database__NAME=forgejo
- FORGEJO__database__USER=forgejo
- FORGEJO__database__PASSWD=forgejo
restart: always
networks:
- forgejo
volumes:
- /mnt/repositories:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "222:22"
```
### Database
PostgreSQL