can't run docker in ubuntu 20.04 - docker

I had tried to install docker like I read in lots of site with the same steps, but it didn't work and always send me that error massage:docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?. and I didn't could find solution that work.
After that I tried to test a bit the sudo snap, and I was surprised to discover that I can install docker using sudo snap install docker and its look like it worked, but when I run the sudo docker run -dt centos bash, I had got the same error.
It's not only a issue with CentOS, I had tried this with kali, mint, ubuntu, and fedora, no one of them worked, and the error is always the same/
thanks for help.

You need to mount /var/run/docker.sock
sudo docker run -dt -v /var/run/docker.sock:/var/run/docker.sock centos bash

Related

Run docker without sudo in ubuntu

Yes I have followed steps provided here https://docs.docker.com/engine/install/ubuntu/ and https://docs.docker.com/engine/install/linux-postinstall/ and also checked this thread docker.sock permission denied
But still getting the below problem when docker is run without sudo in Ubuntu 18.04
docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///run/user/1000/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
It is rather frustrating as I tried multiple times.
It worked fine after deleting the below entry in .bashrc
export DOCKER_HOST=unix:///run/user/1000/docker.sock
I'm not sure how that line made it into .bashrc
Feel so stupid now. Anyway thanks!

Docker not creating directory

I am trying to create a nfs-server using the below command:
docker run -d --rm --privileged --name nfs-server -v /var/folders/nfs:/var/nfs phico/nfs-server:latest
After this command when I check /var/folders I don't see nfs folder.
I logs I see the following :
Starting NFS server ...
Not starting NFS kernel daemon: no support in current kernel. ...
(warning).
NFS server started and listening on 172.17.0.2
Docker Preferences shows that docker has File Sharing Permissions for /var/folders
The logs from pod:
Can somebody help me out.
The issue with MacOS is not resolved but I believe similar solution exists in Mac. But on Ubuntu I had to install nfs-server and nfs-common for it to work.
sudo apt-get install nfs-common
sudo apt-get install nfs-server
You can follow the issue on the author's github page. The author was super helpful and figured out the solution.

Docker issues on Mac

I installed docker using HomeBrew on Mac.
➜ mattermost-server git:(master) docker --version
Docker version 18.09.1, build 4c52b90
➜ mattermost-server git:(master) which docker
/usr/local/bin/docker
When I run docker,
This is the error I get.
➜ mattermost-server git:(master) docker ps
Cannot connect to the Docker daemon at **unix:///var/run/docker.sock.
Is the docker daemon running?**
Update: This can be solved by removing existing docker and running
brew install cask docker
Refer here Cannot connect to the Docker daemon on macOS
I had the same problem after install docker on my mac (brew cask install docker).
docker --version works, but docker ps or any other docker command results in the error:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
To solve the problem you have to :
Install Virtual Box
run : docker-machine create default to create a virtual machine (mandatory
on mac os)
run: docker-machine env default to set the environment
run: eval $(docker-machine env default)
try docker ps or docker version to check that everything is ready.
You are possibly running docker without sudo user, aren't you?
By default you should run docker with sudo user, if you don't want to do that, folow Manage Docker as a non-root user
We need to run brew cask install docker. This should fix the problem.

Docker - cannot connect to the Docker daemon

I'm trying to start a new Docker container with:
docker run -it ubuntu /bin/bash
However I get the following
Checking for the daemon, I get
Any idea what the problem might be?
I had the same kind of problem couple of days ago on LINUX, try below command,use on sudo mode
sudo usermod -aG docker your_user_name
OR
sudo usermod -aG docker $(whoami)
then logout and log in.:) walla
For Mac : see https://stackoverflow.com/users/1978931/dayel-ostraco
I got this problem. In my case, ps showed that the docker daemon was not running. Problem was, I had no clue why.
$ sudo docker -d
attempts to start the daemon manually and displays an error message if it fails.
In my case, my kernel was a bit old and didn't support docker.
There are lots of reason why the daemon may not start, so it's best to find out if it's running and if not, why not.

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