51

On Linux Mint 17.1 x86_64 with kernel 3.13.0-48-generic and OpenSSL version 1.0.1f-1ubuntu2.11; whenever I try to execute any docker command (like docker login or docker run hello-world), I get the following error:

FATA[0000] Get http:///var/run/docker.sock/v1.18/info: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS? 

I have made a group called docker using sudo usermod -aG docker username, I have tried running the commands both as root and normally, added $(boot2docker shellinit 2> /dev/null) to ~/.profile as instructed here, restarted my PC and reinstalled OpenSSL.

Any idea what am I missing? Can this be a hardware issue?

Community
  • 1
  • 1
strNOcat
  • 913
  • 2
  • 8
  • 22
  • 3
    are you using mac os? boot2docker is for the mac. it sounds to me like you haven't started the docker daemon. docker runs in two pieces, the daemon runs in the background. then you connect to the daemon with docker ps, or docker run. When you connect, you are running docker as a client. so, do a ps -ax | grep docker. if it isn't there then do a docker -d (or sudo docker -d) – Greg Apr 17 '15 at 16:10
  • Yes, now it works. For some reason, `docker -d` doesn't seems to be mentioned in the documentation. By the way, is it safe to run it as `docker -d &` so that I get my shell back? – strNOcat Apr 17 '15 at 16:34
  • Since you're using Mint, look for upstart script for docker server – Vitaly Isaev Apr 17 '15 at 21:59
  • Duplicate of [Am I trying to connect to a TLS-enabled daemon without TLS?](http://stackoverflow.com/questions/27528337/am-i-trying-to-connect-to-a-tls-enabled-daemon-without-tls) – Piotr Dobrogost May 20 '16 at 20:18

12 Answers12

23

You can check if it has started by running the command ps -ef. You can also grep it to docker if you want to reduce the number of results(using | grep docker). If its of not running, execute

sudo service docker start

OR if it still doesn't work then

You can refer this link

docker docs

You can run docker run -d or docker run -d & so that you can use the same terminal or even close it if. It will set the value to true, so your container will run in "detached" mode, in the background.

You can also auto start it when your OS starts using update-rc.d servicename defaults or you can also refer to the links below, where you have to give docker as service name and your defaults.

Some more links to refer - auto start, upstart

These are different ways of doing it.

Tejus Prasad
  • 6,322
  • 7
  • 47
  • 75
15

I deployed docker on CentOS 7, and my friend first helped me check whether the process/service docker is actually running or not. He used the command ps -ef | grep docker. It turned out that the process wasn't running at all. Finally, he started this process by using the command service docker start. In the end, the problem was solved.

Tejus Prasad
  • 6,322
  • 7
  • 47
  • 75
Randolph Kevin
  • 157
  • 1
  • 3
9

Try installing apparmor

sudo apt install apparmor

There are other things to look for in this answer too.

Community
  • 1
  • 1
matiasg
  • 1,927
  • 2
  • 24
  • 37
  • i did a fresh installation on ubuntu 12.04 (after update the kernel) and i don't know why give this error, i solved installing apparmor – armandfp May 29 '15 at 10:27
  • 2
    This answers needs more upvotes. The official Docker install instructions for Ubuntu are missing this step. I've installed Docker now three times into clean Ubuntu systems (once running 12.04 and twice running 14.04). Each time I've spent an hour searching the web, only to stumble back to this SO answer! – Doug Schmidt Jun 25 '15 at 00:32
9

I had this same problem when I tried to follow along some online resource; I was able to resolve this by running docker as the super user, try adding sudo before your docker commands:

sudo docker ps -a

sudo docker run hello-world

Hope it helps.

Jikku Jose
  • 18,306
  • 11
  • 41
  • 61
4

I faced the same issue when I was creating docker image from Jenkins simply add the user to docker group and then restart docker services and in my case I have to restart Jenkins services

This was the error which I got

http:///var/run/docker.sock/v1.19/build?cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&memory=0&memswap=0&rm=1&t=59aec062a8dd8b579ee1b61b299e1d9d340a1340: dial unix /var/run/docker.sock: permission denied. Are you trying to connect to a TLS-enabled daemon without TLS?
FATAL: Failed to build docker image from project Dockerfile
java.lang.RuntimeException: Failed to build docker image from project Dockerfile


Solution: 

[root@Jenkins ssh]# groupadd docker
[root@Jenkins ssh]# gpasswd -a jenkins docker
Adding user jenkins to group docker
[root@Jenkins ssh]# /etc/init.d/docker restart
Stopping docker:                                           [  OK  ]
Starting docker:                                           [  OK  ]
[root@Jenkins ssh]# /etc/init.d/jenkins restart
Shutting down Jenkins                                      [  OK  ]
Starting Jenkins                                           [  OK  ]
[root@Jenkins ssh]#
Avinash Singh
  • 1,006
  • 9
  • 10
3

Ran into the same problem this morning. You may just want to do service docker start. It works for centos (Could work for all), and its one of those small nagging things i forget all the time.

Technically when you first install a service such as docker or httpd (apache) it needs actually be started otherwise you will get that error. You can also see the status's of other services by doing service service_name statusbut again, that's how it is for my centos 7.

Jouster500
  • 762
  • 12
  • 25
1

This can happen when the docker service is unable to start. sudo service docker start or restart returning no output does not mean that it started successfully. You can use sudo /etc/init.d/docker status to find out if, and why, it failed to start.

In my case, it was due to lack of disk space.

username@computer:~$ sudo service docker restart
username@computer:~$ sudo /etc/init.d/docker status
? docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: failed (Result: start-limit) since Mon 2015-12-21 15:11:59 PST; 21s ago
     Docs: http://docs.docker.com
  Process: 26463 ExecStart=/usr/bin/docker -d -H fd:// $DOCKER_OPTS (code=exited, status=1/FAILURE)
 Main PID: 26463 (code=exited, status=1/FAILURE)

Dec 21 15:11:59 computer docker[26463]: time="2015-12-21T15:11:59-08:00" level=info msg="Listening for HTTP on fd ()"
Dec 21 15:11:59 computer docker[26463]: time="2015-12-21T15:11:59-08:00" level=info msg="+job init_networkdriver()"
Dec 21 15:11:59 computer docker[26463]: time="2015-12-21T15:11:59-08:00" level=info msg="-job init_networkdriver() = OK (0)"
Dec 21 15:11:59 computer docker[26463]: time="2015-12-21T15:11:59-08:00" level=fatal msg="Shutting down daemon due to errors: Insertion failed because database is full: database or disk is full"
Dec 21 15:11:59 computer systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Dec 21 15:11:59 computer systemd[1]: Unit docker.service entered failed state.
Dec 21 15:11:59 computer systemd[1]: docker.service failed.
Dec 21 15:11:59 computer systemd[1]: start request repeated too quickly for docker.service
Dec 21 15:11:59 computer systemd[1]: Failed to start Docker Application Container Engine.
Dec 21 15:11:59 computer systemd[1]: docker.service failed.

After deleting some files, I was able to restart the service and run docker containers normally.

mboren
  • 11
  • 1
  • 4
1

I solved it by running that command in sudo mode, e.g. "sudo docker images"

Felipe
  • 643
  • 8
  • 13
0

Ran into the same problem after following the steps at https://docs.docker.com/linux/step_one/. docker service was running and I had also added the user to docker group. docker commands were not working without sudo.

What solved it for me was restarting the PC. Note- Before PC restart, I had also tried stopping and starting the docker daemon. I'm on Ubuntu 12.04.

tigeronk2
  • 2,494
  • 2
  • 20
  • 21
  • Further install and config instructions for Ubuntu can be found at https://docs.docker.com/engine/installation/ubuntulinux/. – mkcor Dec 21 '15 at 04:34
0

In my case it was because of file /Users/user/.ssh/config has permissions 777. To check it run in terminal ssh docker@localhost

Londeren
  • 3,202
  • 25
  • 26
0

Ran into the same problem after following the steps at https://docs.docker.com/linux/step_one/. docker service was running and I had also added the user to docker group. docker commands were not working without sudo.

What solved it for me was restarting the PC. Note- Before PC restart, I had also tried stopping and starting the docker daemon. I'm on Ubuntu 12.04.

-3
sudo chmod 777 /var/run/docker.sock
mation4in
  • 15
  • 1
  • 4
    While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. – Donald Duck Mar 17 '17 at 08:40
  • 1
    chmod 777 give the all rights(read,write,execute) to all processes,its bad practice to use 777 but it does solve the problem as you said @DonaldDuck – Eliethesaiyan Mar 30 '17 at 10:39
  • 1
    `chmod 777`? Oh no. – Pang Apr 22 '17 at 07:04