Permission denied /dev/null

Hi All,

I am struggling with permissions problems not running my syncthing docker container under root. When I go in the container as user abc (the user starting my docker container) it gives me below error when I start syncthing in the container:

[monitor] 2023/02/22 14:40:32 WARNING: Error starting the main Syncthing process: open /dev/null: permission denied panic: Error starting the main Syncthing process

Checking per missions for /dev/null it is root/root. So with that syncthing does not get started when the container is not started under the root account on the host.

Does anybody recognize this issue?

/dev/null is used for redirecting unwanted output. It’s normally group readable and writable so the “permission denied” is odd (why the container and/or Syncthing is trying to change the permissions is also curious).

What is your docker-compose .yaml file or command-line parameters look like?

Hi,

I started syncthing in docker with below composer file (very default):

---
version: "2.1"
services:
  syncthing:
    image: lscr.io/linuxserver/syncthing:latest
    container_name: Syncthing
    hostname: Syncthing #optional
    network_mode: host
    environment:
      - PUID=0
      - PGID=0
#      - PUID=1000
#      - PGID=1000
      - TZ=Europe/Amsterdam
    volumes:
      - /SSD/config/Syncthing:/config
      - /DATA:/data1
      - /DATA:/data2
    ports:
      - 8384:8384
      - 22000:22000/tcp
      - 22000:22000/udp
      - 21027:21027/udp
    restart: unless-stopped

It is now started with root and runs with no issues. But when I start it with another user, user 1000. Then it does not start correctly. When I go into the container and start syncthing manually (with user account 1000). It immediately give below error message

[monitor] 2023/02/22 14:40:32 WARNING: Error starting the main Syncthing process: open /dev/null: permission denied panic: Error starting the main Syncthing process

When I do into the container as root I can start Syncthing manually with no problem.

I start Syncthing with below compose file:

---
version: "2.1"
services:
  syncthing:
    image: lscr.io/linuxserver/syncthing:latest
    container_name: Syncthing
    hostname: Syncthing #optional
    network_mode: host
    environment:
      - PUID=0
      - PGID=0
#      - PUID=1000
#      - PGID=1000
      - TZ=Europe/Amsterdam
    volumes:
      - /SSD/config/Syncthing:/config
      - /DATA:/data1
      - /DATA:/data2
    ports:
      - 8384:8384
      - 22000:22000/tcp
      - 22000:22000/udp
      - 21027:21027/udp
    restart: unless-stopped

Now it runs fine with root. But when I start it with user 1000 then it doe sniot start. When I go into the contrainer with user 1000 and start Syncthing manually it gives below error:

[monitor] 2023/02/22 14:40:32 WARNING: Error starting the main Syncthing process: open /dev/null: permission denied panic: Error starting the main Syncthing process

I can start Syncthing manually in the container with root.

There’s lots of hits on the internet for “docker permission denied /dev/null”. Maybe look into this; this looks like a Docker or system problem, not really a Syncthing issue. Also, the linuxserver/syncthing image does a lot of magic on startup, maybe try our image instead to see if it makes a difference (though honestly I don’t think that’s the problem).

I have now started this Syncthing docker container in privileged mode. And then it runs nicely. So the container is now not started as root anymore but in privileged mode in docker.

So this was a docker issue and not a Syncthing issue.

Thanks

Reading further, this is also not a good alternative to run a container in privileged mode.

Will investigate further and update when I found the issue.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.