美文网首页吉良吉影
ubuntu docker命令免sudo 执行

ubuntu docker命令免sudo 执行

作者: 百工之人 | 来源:发表于2020-01-15 14:22 被阅读0次

    小白安装docker的时候遇到的一个炒鸡大坑

    docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/create: dial unix /var/run/docker.sock: connect: permission denied.

    电脑配置

                              ./+o+-       用户名@主机名
                      yyyyy- -yyyyyy+      OS: Ubuntu 18.04 bionic
                   ://+//////-yyyyyyo      Kernel: x86_64 Linux 4.15.0-72-generic
               .++ .:/++++++/-.+sss/`      Uptime: 6m
             .:++o:  /++++++++/:--:/-      Packages: 4914
            o:+o+:++.`..```.-/oo+++++/     Shell: zsh 5.4.2
           .:+o:+o/.          `+sssoo+/    Resolution: 1280x1024
      .++/+:+oo+o:`             /sssooo.   DE: XFCE
     /+++//+:`oo+o               /::--:.   WM: Xfwm4
     \+/+o+++`o++o               ++////.   WM Theme: Mojave-light
      .++.o+++oo+:`             /dddhhh.   GTK Theme: TraditionalOk [GTK2]
           .+.o+oo:.          `oddhhhh+    Icon Theme: Tela
            \+.++o+o``-````.:ohdhhhhh+     Font: Sans 10
             `:o+++ `ohhhhhhhhyo++os:      CPU: Intel Core i5-6500 @ 4x 3.6GHz [53.0°C]
               .o:`.syhhhhhhh/.oo++o`      GPU: Mesa DRI Intel(R) HD Graphics 530 (Skylake GT2) 
                   /osyyyyyyo++ooo+++/     RAM: 714MiB / 15920MiB
                       ````` +oo+++o\:    
                              `oo++.      
    
    

    问题:

    ╰─$ docker run hello-world
    docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
    See 'docker run --help'.
    

    解决办法:
    临时对策,未找到永久对策。
    How to fix docker: Got permission denied while trying to connect to the Docker daemon socket
    打不开连接看下面:

        ubuntu@ip-172-31-21-106:/var/run$ ls -lrth docker.sock
        srw-rw---- 1 root root 0 Oct 17 11:08 docker.sock
        ubuntu@ip-172-31-21-106:/var/run$ sudo chmod 666 /var/run/docker.sock
        ubuntu@ip-172-31-21-106:/var/run$ ls -lrth docker.sock
        srw-rw-rw- 1 root root 0 Oct 17 11:08 docker.sock
    

    /var/run/docker.sock文件的权限改为666
    有的系统路径在/run/docker.sock

    参考

    ubuntu docker命令免sudo 执行
    Ubuntu下docker使用非root权限运行docker
    史上最全Docker环境安装指南

    相关文章

      网友评论

        本文标题:ubuntu docker命令免sudo 执行

        本文链接:https://www.haomeiwen.com/subject/hkstzctx.html