unable to configure the Docker daemon with file /etc/docker/daemon.json: EOF - linux

I am new to docker and cannot understand these errors. So, Please let me know if any more information is needed.
`$ docker --version`
Docker version 1.12.6, build 88a4867/1.12.6
`$ docker info`
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
`$sudo dockerd`
FATA[0000] unable to configure the Docker daemon with file /etc/docker/daemon.json: EOF
`$sudo systemctl start docker`
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
`$sudo systemctl status docker.service -l`
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2017-07-26 14:30:21 EDT; 8min ago
Docs: http://docs.docker.com
Process: 5835 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --authorization-plugin=rhel-push-plugin --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY (code=exited, status=1/FAILURE)
Main PID: 5835 (code=exited, status=1/FAILURE)
Jul 26 14:30:21: Starting Docker Application Container Engine...
Jul 26 14:30:21 dockerd-current[5835]: time="2017-07-26T14:30:21-04:00" level=fatal msg="unable to configure the Docker daemon with file /etc/docker/daemon.json: EOF\n"
Jul 26 14:30:21 systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Jul 26 14:30:21 systemd[1]: Failed to start Docker Application Container Engine.
Jul 26 14:30:21 systemd[1]: Unit docker.service entered failed state.
Jul 26 14:30:21 systemd[1]: docker.service failed.
Please let me know if I need to check anything else.

The file /etc/docker/daemon.json should not be present or if it is present then it should have a valid JSON object. A blank file would create an error. Either delete the file or if you want to have a blank file then have it with below content
{
}
This will create a blank json object

I have same problem. But I am edited the file /etc/docker/daemon.json and added to it some options. If string with option is not last it have to end with comma character(,).

In root user, type :
$ nano /etc/docker/daemon.json
Ff the file show blank or nothing text, then you just add :
{
}
then save and exit.
Then try to restart docker using
$ service docker restart

In my case just remove that's file using this command
$sudo rm /etc/docker/daemon.json
and then restar the service
$sudo systemctl restart docker.service
$sudo systemctl status docker.service

Related

How to fix permission denied issue RedisJson?

When I try to load a redis module with loadmodule in redis.conf, redis-server crashes.
The log shows
Module /etc/modules/librejson.so failed to load: /etc/modules/librejson.so: unable to open shared objects file: Permission denied.
I have read the documentation to install RedisJson, but it does not work for me.
If I comment loadmodule line, the server works fine.
Installation process
sudo dnf update
sudo dnf upgrade
sudo dnf install redis
Configuration
cd /etc/redis
nvim /redis.conf
loadmodule loadmodule /etc/modules/librejson.so
supervised systemd
The rest of the file is kept by default
What I did
I created modules folder inside etc folder
I ran chown redis:root over modules folder
I moved the module to /etc/modules because I had read that homeprotection can block redis when trying to read the module in the /home path.
Then I used ls -l to check permissions and owners:
-rwxr-xr-x. 2 user user user 23668904 Feb 15 09:10 librejson.so
after that, I ran chown redis:root (as redis.conf owners): -rwxr-xr-xr-x. 2 redis root 23668904 Feb 15 09:10 librejson.so
and when I ran sudo systemctl restart redis.service:
Job for redis.service failed because the control process exited with error code.
See "systemctl status redis.service" and "journalctl -xeu redis.service" for details.
systemctl status redis.service:
redis.service - Redis persistent key-value database
Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; preset: disabled)
Drop-In: /etc/systemd/system/redis.service.d
└─limit.conf
Active: failed (Result: exit-code) since Thu 2023-02-16 13:21:58 CST; 6min ago
Process: 28947 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf --daemonize no --supervised systemd (code=exited, status=1/FAILURE)
Main PID: 28947 (code=exited, status=1/FAILURE)
Status: "Redis is loading..."
CPU: 10ms
Feb 16 13:21:58 fedora systemd[1]: Starting redis.service - Redis persistent key-value database...
Feb 16 13:21:58 fedora systemd[1]: redis.service: Main process exited, code=exited, status=1/FAILURE
Feb 16 13:21:58 fedora systemd[1]: redis.service: Failed with result 'exit-code'.
Feb 16 13:21:58 fedora systemd[1]: Failed to start redis.service - Redis persistent key-value database.
and nothing, I ran out of ideas.
System specs
Fedora 37
Redis server v=7.0.8

Docker Issue - Failed to start Docker Application Container Engine (code=exited, status=1/FAILURE)

I am fairly new to docker and linux and I am having issue installing and running docker. My system config are
Operating System: Debian GNU/Linux 9 (stretch)
Kernel: Linux 5.13.9.rsk.1-amd64
Architecture: x86-64
I followed official instructions. When I run sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin, it had following error
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package docker-compose-plugin
I also tried, sudo systemctl restart docker, which output
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xe" for details.
Then I tried, sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2022-06-10 23:04:17 CST; 1min 41s ago
Docs: https://docs.docker.com
Main PID: 33878 (code=exited, status=1/FAILURE)
CPU: 111ms
Jun 10 23:04:15 6969-69-696 systemd[1]: docker.service: Unit entered failed state.
Jun 10 23:04:15 6969-69-696 systemd[1]: docker.service: Failed with result 'exit-code'.
Jun 10 23:04:17 6969-69-696 systemd[1]: docker.service: Service hold-off time over, scheduling restart.
Jun 10 23:04:17 6969-69-696 systemd[1]: Stopped Docker Application Container Engine.
Jun 10 23:04:17 6969-69-696 systemd[1]: docker.service: Start request repeated too quickly.
Jun 10 23:04:17 6969-69-696 systemd[1]: Failed to start Docker Application Container Engine.
Jun 10 23:04:17 6969-69-696 systemd[1]: docker.service: Unit entered failed state.
Jun 10 23:04:17 6969-69-696 systemd[1]: docker.service: Failed with result 'exit-code'.
journalctl -xe had a very big output which does not seem related to docker (most outputs are Failed to get GPU/HCU type or it is not a GPU/HCU host which would make sense since it is a remote host machine).
I have looked at other similar questions on stackoverflow and those fixes have not worked for me so far. Please let me know if I should be doing something differently or how can I fix it. I really need to get docker running for my work. Any help will be appreciated.

Run the program with Docker

I want to run the program on a VPS server Ubuntu 18.04. It must be run with Docker with this command:
docker run --rm --name aparser -v $(pwd)/aparser:/app -p 9091:9091 -t aparser/runtime./aparser -foreground
But I get an error:
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
Inputting
sudo systemctl status docker.service
I get:
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2022-05-25 09:31:14 UTC; 14min ago
Docs: https://docs.docker.com
Process: 30302 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1 Main PID: 30302 (code=exited, status=1/FAILURE)
May 25 09:31:12 p619677.vps systemd[1]: docker.service: Main process exited,code=exited, status=1/FAILURE
May 25 09:31:12 p619677.vps systemd[1]: docker.service: Failed with result 'exit-code'.
May 25 09:31:12 p619677.vps systemd[1]: Failed to start Docker Application Container Engine.
May 25 09:31:14 p619677.vps systemd[1]: docker.service: Service hold-off time over, scheduling restart.
May 25 09:31:14 p619677.vps systemd[1]: docker.service: Scheduled restart job, restart counter is at 5.
May 25 09:31:14 p619677.vps systemd[1]: Stopped Docker Application Container Engine.
May 25 09:31:14 p619677.vps systemd[1]: docker.service: Start request repeated too quickly.
May 25 09:31:14 p619677.vps systemd[1]: docker.service: Failed with result 'exit-code'.
May 25 09:31:14 p619677.vps systemd[1]: Failed to start Docker Application Container Engine.
lines 1-16/16 (END)
You will run docker daemon before run docker container.
Run command for start docker service
sudo systemctl start docker
After starting docker you can run with your command and sudo if you are not in sudo
sudo docker run --rm --name aparser -v $(pwd)/aparser:/app -p 9091:9091 -t aparser/runtime./aparser -foreground
If systemctl not working for you run
sudo service docker start
This server does not support Docker.

Docker service hosts config failed to start

I have Debian 10 virtual machine.
And I want to be able to connect to the docker API from another host.
I can connect to docker from other host if I start docker deamon from console
dockerd -H unix:///var/run/docker.sock -H tcp://192.168.3.157
If I try to configure /etc/docker/daemon.json like
{
"hosts": ["unix:///var/run/docker.sock", "tcp://192.168.3.157"]
}
The command systemctl start docker fails. The command systemctl status docker have next output
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2019-11-02 11:32:26 MSK; 1min 10s ago
Docs: https://docs.docker.com
Process: 868 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
Main PID: 868 (code=exited, status=1/FAILURE)
Nov 02 11:32:24 debian-for-docker systemd[1]: Failed to start Docker Application Container Engine.
Nov 02 11:32:26 debian-for-docker systemd[1]: docker.service: Service RestartSec=2s expired, scheduling restart.
Nov 02 11:32:26 debian-for-docker systemd[1]: docker.service: Scheduled restart job, restart counter is at 3.
Nov 02 11:32:26 debian-for-docker systemd[1]: Stopped Docker Application Container Engine.
Nov 02 11:32:26 debian-for-docker systemd[1]: docker.service: Start request repeated too quickly.
Nov 02 11:32:26 debian-for-docker systemd[1]: docker.service: Failed with result 'exit-code'.
Nov 02 11:32:26 debian-for-docker systemd[1]: Failed to start Docker Application Container Engine.
Nov 02 11:32:53 debian-for-docker systemd[1]: docker.service: Start request repeated too quickly.
Nov 02 11:32:53 debian-for-docker systemd[1]: docker.service: Failed with result 'exit-code'.
Nov 02 11:32:53 debian-for-docker systemd[1]: Failed to start Docker Application Container Engine.
How should I configure the /etc/docker/daemon.json to make my deamon start properly?
I have found the answer.
It's here Unable to start docker after configuring hosts in daemon.json
I have created the file /etc/systemd/system/docker.service.d/override.conf with content
# Disable flags to dockerd, all settings are done in /etc/docker/daemon.json
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd
And then I restarted the service systemctl daemon-reload; systemctl restart docker

systemd stops process even with incorrect ExecStop

I'm trying to manage multiple redis instances with systemd. Below is my systemd unit file
[Unit]
Description=Redis instances
After=network.target
[Service]
Type=simple
ExecStart=/home/redis/bin/redis-server /home/redis/conf/redis-%i.conf
ExecStop=/home/redis/bin/redis-cli -p %i INFO # <= INFO should not stop redis process
User=redis
Group=redis
[Install]
WantedBy=multi-user.target
I could successfully start redis-server by
$ sudo systemctl start redis#6379
$ systemctl status redis#6379
● redis#6379.service - Redis instances
Loaded: loaded (/usr/lib/systemd/system/redis#.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2017-09-05 17:48:42 JST; 2h 52min ago
Main PID: 86962 (redis-server)
CGroup: /system.slice/system-redis.slice/redis#6379.service
└─86962 /home/redis/bin/redis-server 0.0.0.0:6379 [cluster]
As a test of stopping redis-server, I intentionally used INFO instead of SHUTDOWN at the ExecStop line.
But when I executed below command, systemd still killed my redis process.
sudo systemctl stop redis#6379
And there's no output by:
sudo journalctl -f -u redis#6379
I wonder how could this happen ?
PS:
I replaced redis-cli with an non-exist one:
ExecStop=/tmp/nonexist
journalctl showed error log like:
Sep 05 20:51:57 myhost systemd[96306]: Failed at step EXEC spawning /tmp/nonexist: No such file or directory
Sep 05 20:51:57 myhost systemd[1]: redis#6379.service: control process exited, code=exited status=203
Sep 05 20:51:57 myhost systemd[1]: Unit redis#6379.service entered failed state.
Sep 05 20:51:57 myhost systemd[1]: redis#6379.service failed.
But the running redis process was still killed.

Resources