Sunday, April 10, 2022

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

Issue

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

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.



Answered By - Bib
Answer Checked By - Marie Seifert (WPSolving Admin)