how can i made docker work with my user (ubuntu) - docker

this is the current situation:
hamsterofdeath#HodVm:~$ docker ps
Cannot connect to the Docker daemon at unix:///home/hamsterofdeath/.docker/desktop/docker.sock. Is the docker daemon running?
hamsterofdeath#HodVm:~$ sudo docker ps
[sudo] password for hamsterofdeath:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
hamsterofdeath#HodVm:~$ docker ps
Cannot connect to the Docker daemon at unix:///home/hamsterofdeath/.docker/desktop/docker.sock. Is the docker daemon running?
hamsterofdeath#HodVm:~$ sudo groupadd docker
groupadd: group 'docker' already exists
hamsterofdeath#HodVm:~$ sudo gpasswd -a ${USER} docker
Adding user hamsterofdeath to group docker
hamsterofdeath#HodVm:~$ docker ps
Cannot connect to the Docker daemon at unix:///home/hamsterofdeath/.docker/desktop/docker.sock. Is the docker daemon running?
hamsterofdeath#HodVm:~$
cat /etc/group gives me "docker:x:996:hamsterofdeath"
logging out and in again changes nothing. i also tried:
sudo usermod -aG docker $USER
sudo usermod -a -G docker $USER
but it has no effect. what do i need to do?
i always get:
Cannot connect to the Docker daemon at unix:///home/hamsterofdeath/.docker/desktop/docker.sock. Is the docker daemon running?
or
Error response from daemon: dial unix /home/hamsterofdeath/.docker/desktop/docker.raw.sock: connect: connection refused
with sudo, it works
there might be another(?) problem
i removed docker via
sudo apt remove docker
but the "docker" command still exists.
amsterofdeath#HodVm:~$ sudo apt remove docker
[sudo] password for hamsterofdeath:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'docker' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
hamsterofdeath#HodVm:~$ docker ps
Cannot connect to the Docker daemon at unix:///home/hamsterofdeath/.docker/desktop/docker.sock. Is the docker daemon running?
hamsterofdeath#HodVm:~$

Waht you could try:
Try restarting the bash process and probably the machine.
See if the docker group is associated with the .sock file
This should return nothing:
stat -c %U:%G /home/hamsterofdeath/.docker/desktop/docker.raw.sock | grep -v root:docker
if it does do:
chown root:docker /home/hamsterofdeath/.docker/desktop/docker.raw.sock
Is $USER filled with the correct data ?
Restart docker engine using sudo systemctl
Else go to Post-Install and try all the steps there especially since it seems to an VM restart it
Next Docker Desktop is rather sketchy. I personally recommend using the VS-Code Docker extension as it offers almost the same functionality as docker desktop and works fine with Ubuntu. See Docker Extension VS-Code

Related

docker is not running as rootless

i had install docker on arch Manjaro
had try
sudo usermod -aG docker $USER
it is added to the user
id arch
uid=1000(arch) gid=1001(arch) groups=1001(arch),998(wheel),991(lp),3(sys),90(network),98(power),1000(autologin),962(docker)
docker ps
Cannot connect to the Docker daemon at unix:///home/arch/.docker/desktop/docker.sock. Is the docker daemon running?
*i have to edit a file that present in docker but iam not able to *

Failed to connect to bus: Host is down in ubuntu

"sudo systemctl enable --now docker" while running this command I'm getting an error like "System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down"
How can I fix this and I'm new to Ubuntu commands.
Please refer to Latest Docker Documentation; Older versions of Docker don't play nicely.
The trick is to uninstall sudo apt-get remove docker docker.io containderd, etc... And add the docker GPG key and setup the repository (documented in link). Then install sudo apt-get install docker-ce docker-ce-cli containerd.io instead.
Once you've removed old docker from your Ubuntu installation, you can then go sudo service docker start to have docker daemon running without systemctl and use service instead.
I am using ubuntu:20.04 Image.
I encountered the same error while trying to use systemctl command inside the ubuntu docker container, since the system has not been booted with systemd as init system (PID 1) as the error says so in order to fix that you will need to start you container using this
docker run -ti -d ubuntu:20.04 "/sbin/init"
In fact, running the container will cause an error:
I have solvedcontroller_1 | Failed to mount tmpfs at /run: Operation not permitted
container_1 | Failed to mount tmpfs at /run/lock: Operation not permitted
container_1 | [!!!!!!] Failed to mount API filesystems.
container_1 | Freezing execution.
By default, the container is not authorized to access any device, but a container with a "privileged" tag grants its root capabilities to all devices on the host system that will give access to the container to mount API filesystems and solve the issue.
in order to fix that you will need to
docker run -ti -d --privileged ubuntu:20.04 "/sbin/init"

Intellij Idea: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Even though my user is on docker group and I can launch docker without sudo, and I'm running idea.sh from my user, whenever I try to connect to docker from within Intellij Idea docker plugin, I get
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
I'm trying the Unix socket method. I already tried multiple restarts and logout.
I'm on Ubuntu 20.04 and Intellijd Idea 2020.3
Adding current user to docker group worked for me:
sudo gpasswd -a ${USER} docker
You might need to create group first:
sudo groupadd docker
restart your OS after those changes
For me it work
sudo chmod 0777 /var/run/docker.sock
Then test this in the terminal without the sudo
docker ps -a
normally you should have access to the docker process

Unable to sudo docker pull ubuntu from windows-ubuntu

syed#DESKTOP-E396P7V:~$ sudo systemctl status ssh
Failed to connect to bus: No such file or directory
syed#DESKTOP-E396P7V:~$ sudo docker pull ubuntu
Using default tag: latest
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
syed#DESKTOP-E396P7V:~$ sudo docker.io pull ubuntu
sudo: docker.io: command not found
syed#DESKTOP-E396P7V:~$
Your docker daemon is not running, run it by executing sudo systemctl start docker

Docker not working after installation

I tried installing the docker using the linux method.
However when the command $docker run hello-world is executed, it outputs:
docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
See 'docker run --help'.
What can be done about this?
First of all make sure the daemon is running:
$ps aux|grep "docker daemon"|grep -v "grep"
A) The daemon is not launched (no lines are returned by the ps)
Start the daemon that is not working:
$sudo /usr/bin/docker daemon -H unix:///var/run/docker.sock
Or start it as a service with:
$sudo /usr/sbin/service docker start
At this point the daemon is launched.
B) The daemon is launched
As shown by the ps with something like:
[..] /usr/bin/docker daemon -H unix:///var/run/docker.sock
You're good to go with your first container with a:
$sudo docker run hello-world.
sudo and docker
If you want to use docker without being sudo (this you should, though you must be aware of the security warning!) a good read of this will help you.
You have to run this command as sudo.
sudo docker run hello-world
This will give you enough privileges to perform that action.
If you want to enable your user to rung docker without sudo, then check out this answer.

Resources