docker: Cannot connect to the Docker daemon on Mac OS X - docker

I got the following error when I run docker. Does anybody know how to fix the problem. The OS is Mac OS X.
$ docker --version
Docker version 17.12.0-ce, build c97c6d6
$ docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.

You can restart Docker with the following
Stop Docker for Mac gracefully
Stop all Docker containers without confirmation (make sure nothing is running in Docker)
docker ps -q | xargs -L1 docker stop
Requires all Docker containers are stopped
test -z "$(docker ps -q 2>/dev/null)" && osascript -e 'quit app "Docker"'
Start Docker gracefully
open --background -a Docker

I just found out that I have to restart my docker desktop as well. I had no idea that docker desktop and terminal's docker command are related. But now, apparently, they are related. If anyone encounters similar problems, remember to try restart your docker desktop and wait for it to get running!

Related

How to reboot centos in docker?

How to reboot centos in docker ?
I had pulled centos 7 from docker
use the 'shutdown -r now'
The console said 'Failed to talk to init daemon.'
I also used 'reboot -f' , and get the
'Rebooting.
Failed to reboot: Operation not permitted' for rsp
Why you want to restart container?
if it is necessary you can use
docker exec -it <container name> reboot
or you can stop container and start it again
docker stop -f <container name>
then
docker start <container name>
Assuming you are logged in to your container and trying to "reboot" the container:
e.g. docker run -i -t centos /bin/bash
and then reboot
You shouldn't do is.
Please use docker run/start/stop....

Docker in Docker(DND) is not starting

I have a simple Ubuntu 16.10 container which has docker.io installed.
The docker process terminates after it starts and log has this information. Any troubleshooting suggestions?
$ docker run -it --name dcos-ubuntu-python5 python-docker /bin/bash
root#5ff6bb6b6dc7:/# docker run hello-world
docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
See 'docker run --help'.
root#5ff6bb6b6dc7:/# service docker start
* Starting Docker: docker [ OK ]
root#5ff6bb6b6dc7:/# service docker status
* Docker is not running
root#5ff6bb6b6dc7:/# tail -f /var/log/docker.log
time="2017-12-21T17:09:45.464736873Z" level=info msg="libcontainerd: new containerd process, pid: 50"
time="2017-12-21T17:09:46.472578239Z" level=fatal msg="Error starting daemon: error initializing graphdriver: operation not permitted"
Why do you want to run docker within docker container?
Docker-in-Docker is developed to help docker development. And it needs --privileged flag to run docker container.(Please read jpetazzo's blog here.)
If you really want to execute docker in docker container, you also have other options.
Bind mount docker.sock. Some people call this DooD(Docker-outside-of-Docker)
docker run -v /var/run/docker.sock:/var/run/docker.sock ...
Install docker(client) and specify DOCKER_HOST to access remote docker daemon. Be careful about socket protection with certificates.
Are you running docker as sudo if not run as sudo or
Else add user group to docker
docker group. For this run following command:
sudo usermod -aG docker $USER
The answer was simple.
docker run -it --privileged --name dcos-ubuntu-python5 python-docker /bin/bash
(This was also mentioned partly in #SunghoMoon's response. So Credits to him).

Can't run Raspbian container on docker

So I've installed the hypriot OS for docker and I have tested it with ocker run -d -p 80:80 hypriot/rpi-busybox-httpd. All is well and the test works.
However, when I run docker run -i -t resin/rpi-raspbian to get raspbian nothing happens and docker ps shows no containers running. There are no error messages.
What is happening to my raspbian container?
Thanks
Running on Mac OSX and having downloaded the resin/rpi-raspbian image, I issue the command:
docker run -i -t resin/rpi-raspbian /bin/bash
which starts the container and puts me at the command prompt in raspbian.

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.

Docker daemon fails

I am using Ubuntu 14.04 on Dell Latitude E6430 and have installed docker.io package. Now whenever I restart my system, first docker command fails with message
Cannot connect to the Docker daemon. Is 'docker -d' running on this host?
Hence to fix this i run below command and daemon works like charm
ps -ef |grep docker
kill -9 *pid found* | rm /var/run/docker.pid
I have check previous questions and none answer this behaviour
Any idea why is breaking ?

Resources