[docker:latest] SSH not working - "/var/empty must be owned by root" #9735

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

Originally created by @svilenmarkov on GitHub (Oct 25, 2022).

Description

I've had gitea running with docker for a few weeks now but yesterday noticed I couldn't push/pull/fetch/basically anything SSH related. Doing docker logs -f gitea I could see this getting printed every second or so:

/var/empty must be owned by root and not group or world-writable.

So I did just that inside the container:

chown -R root:root /var/empty

Logs then immediately showed:

Server listening on :: port 22.
Server listening on 0.0.0.0 port 22.

And everything was working perfectly fine again.

I'm not sure what I've done to get to this state but I get the same result every time I delete the container and recreate it. I also tried using an empty directory for the /data volume to check if somehow the data I have is breaking it but it's behaving the same way.

Gitea Version

1.17.3

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

2.36.2

Operating System

Debian 11

How are you running Gitea?

Docker compose:

gitea:
    container_name: gitea
    image: gitea/gitea:latest
    restart: unless-stopped
    environment:
      - GITEA__server__DOMAIN=my.domain
      - GITEA__server__SSH_DOMAIN=my.domain
      - GITEA__server__ROOT_URL=https://my.domain
      - GITEA__server__SSH_PORT=222
    ports:
      - 222:22
    volumes:
      - /storage/gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    networks:
      - gitea

Database

No response

Originally created by @svilenmarkov on GitHub (Oct 25, 2022). ### Description I've had gitea running with docker for a few weeks now but yesterday noticed I couldn't push/pull/fetch/basically anything SSH related. Doing `docker logs -f gitea` I could see this getting printed every second or so: ``` /var/empty must be owned by root and not group or world-writable. ``` So I did just that inside the container: ``` chown -R root:root /var/empty ``` Logs then immediately showed: ``` Server listening on :: port 22. Server listening on 0.0.0.0 port 22. ``` And everything was working perfectly fine again. I'm not sure what I've done to get to this state but I get the same result every time I delete the container and recreate it. I also tried using an empty directory for the `/data` volume to check if somehow the data I have is breaking it but it's behaving the same way. ### Gitea Version 1.17.3 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version 2.36.2 ### Operating System Debian 11 ### How are you running Gitea? Docker compose: ```yml gitea: container_name: gitea image: gitea/gitea:latest restart: unless-stopped environment: - GITEA__server__DOMAIN=my.domain - GITEA__server__SSH_DOMAIN=my.domain - GITEA__server__ROOT_URL=https://my.domain - GITEA__server__SSH_PORT=222 ports: - 222:22 volumes: - /storage/gitea:/data - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro networks: - gitea ``` ### Database _No response_
GiteaMirror added the type/bugissue/workaround labels 2025-11-02 08:47:58 -06:00
Author
Owner

@Polarolouis commented on GitHub (Nov 9, 2022):

I'm facing the exact same issue

EDIT:
A lazy workaround I just found, is adding the following line to the serverblock in my docker-compose.yml:

command: /bin/sh -c "chown root:root /var/empty && /usr/bin/entrypoint"
@Polarolouis commented on GitHub (Nov 9, 2022): I'm facing the exact same issue **EDIT**: A lazy workaround I just found, is adding the following line to the `server`block in my docker-compose.yml: ```yaml command: /bin/sh -c "chown root:root /var/empty && /usr/bin/entrypoint" ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#9735