Linux 下非root用戶使用docker


Linux 下非root用戶使用docker

通常我們使用linux系統的時候,最好是不要直接使用root賬號,但是使用Docker的時候,默認又是不能使用非root用戶的,關於原因,官方說法如下:

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 access it with sudo. For this reason, docker daemon always runs as the root user.
To avoid having 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.

下面是讓非root用戶可用root的步驟:

1

創建docker組

sudo groupadd docker

2

將當前用戶加入docker組

sudo gpasswd -a ${USER} docker

3

重新啟動docker服務(下面是CentOS7的命令)

sudo systemctl restart docker

4

當前用戶退出系統重新登陸

5

運行docker命令,測試

docker ps

參考:http://blog.csdn.net/kongxx/article/details/52413332


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM