0

"/etc/docker/daemon.json" "/etc/docker/daemon.json" E212: Can't open file for writing

I’m currently trying to set up a Loki server, Promtail, and Grafana as docker images

I installed all the plugins needed however when I tried editing the docker daemon config file with this command

sudo nano /etc/docker/daemon.json

It does not allow me to write due to permissions so I tried using

sudo vi chmod 666 /etc/docker/daemon.json

but this only creates a new file in my directory called chmod

The docker containers are up but I can't see the Loki metrics on my web browser when I try to use localhost:3100/metrics neither can it can be added as a Datasource

Please can you help?

  • 1
    Note that questions that are about using UNIX tools, not about writing software, are better asked at [unix.se]. – Charles Duffy Feb 19 '22 at 17:17
  • 1
    Also, making a configuration file world-writable is an _extremely_ bad idea. It's generally better to err on the side of things being explicitly broken as opposed to "working"-but-insecure -- it's easier to fix something that simply doesn't work than to remove a rootkit someone injected into your system because you "fixed" it the fast way instead of the right way. – Charles Duffy Feb 19 '22 at 17:18

1 Answers1

1

It should be sudo chmod 666 /etc/docker/daemon.json.

What you are doing is running vi against 3 files, chmod, 666, /etc/docker/daemon.json.

The directory /etc/docker must also exist as a directory, and not as a file.

Bib
  • 922
  • 1
  • 5
  • 10