Am I trying to connect to a TLS-enabled daemon without TLS?

前端 未结 20 2267
暗喜
暗喜 2020-11-28 17:56

I\'m trying to learn about Docker, but I keep getting cryptic (to me) error messages.

Possibly the simplest example of this is trying to print the version of Docker

相关标签:
20条回答
  • 2020-11-28 18:36

    I faced the same issue when I was creating Docker images from Jenkins. Simply add the user to the docker group and then restart Docker services and in my case I had 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]#
    
    0 讨论(0)
  • 2020-11-28 18:37

    For what it is worth, I tried all the solutions in this question and in this related question and none resolved my issue until I uninstalled and re-installed VirtualBox. This process upgraded the VirtualBox from version 4.2.16 to 4.3.22 (my previous one had been lying unused on the system for a few months).

    Then boot2docker and docker worked without any other adjustments.

    0 讨论(0)
  • 2020-11-28 18:39

    For me the following steps worked:

    1. I noticed that running docker run hello-world fails with this socked error as in the question, but running sudo docker run hello-world worked.
    2. I added my current user to the docker group, sudo adduser user docker. Then you must restart your machine or use su - user (check using groups command if are in the docker group).

    After that, hello-world started to work.

    My answer is based on How can I use docker without sudo? which explains what go wrong.


    0 讨论(0)
  • 2020-11-28 18:40

    Everything that you need to run Docker on Linux Ubuntu/Mint:

    sudo apt-get -y install lxc
    sudo gpasswd -a ${USER} docker
    newgrp docker
    sudo service docker restart
    

    Optionally, you may need to install two additional dependencies if the above doesn't work:

    sudo apt-get -y install apparmor cgroup-lite
    sudo service docker restart
    
    0 讨论(0)
  • 2020-11-28 18:41

    Make sure there is

    127.0.0.1    localhost
    

    in your

    `/etc/hosts `
    

    file.

    0 讨论(0)
  • 2020-11-28 18:43

    The Docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can only access it using sudo. The Docker daemon always runs as the root user.

    sudo groupadd docker
    sudo usermod -aG docker $USER
    

    Log out and log back in so that your group membership is re-evaluated.

    docker run hello-world
    

    Source: Manage Docker as a non-root user

    0 讨论(0)
提交回复
热议问题