'How to force open a file in linux as a normal user [closed]

"/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?



Solution 1:[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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1