日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > Ubuntu >内容正文

Ubuntu

ubuntu docker报错

發(fā)布時(shí)間:2024/1/17 Ubuntu 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ubuntu docker报错 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

以下問(wèn)題及解決方法都在Ubuntu16.04下,其他環(huán)境類似

問(wèn)題描述

安裝完docker后,執(zhí)行docker相關(guān)命令,出現(xiàn)

”Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.26/images/json: dial unix /var/run/docker.sock: connect: permission denied“

原因

摘自docker mannual上的一段話

Manage Docker as a non-root user

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.

If you don’t want to use sudo when you use the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.

大概的意思就是:docker進(jìn)程使用Unix Socket而不是TCP端口。而默認(rèn)情況下,Unix socket屬于root用戶,需要root權(quán)限才能訪問(wèn)。
解決方法1

使用sudo獲取管理員權(quán)限,運(yùn)行docker命令
解決方法2

docker守護(hù)進(jìn)程啟動(dòng)的時(shí)候,會(huì)默認(rèn)賦予名字為docker的用戶組讀寫Unix socket的權(quán)限,因此只要?jiǎng)?chuàng)建docker用戶組,并將當(dāng)前用戶加入到docker用戶組中,那么當(dāng)前用戶就有權(quán)限訪問(wèn)Unix socket了,進(jìn)而也就可以執(zhí)行docker相關(guān)命令

sudo groupadd docker #添加docker用戶組 sudo gpasswd -a $USER docker #將登陸用戶加入到docker用戶組中 newgrp docker #更新用戶組 docker ps #測(cè)試docker命令是否可以使用sudo正常使用

轉(zhuǎn)載于:https://www.cnblogs.com/plusUltra/p/11206943.html

總結(jié)

以上是生活随笔為你收集整理的ubuntu docker报错的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。