解決非root用戶使用docker的辦法

一般咱們使用Docker的時候都是使用的root,官方說法以下docker

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.shell

下面是使用非root用戶操做的步驟bash

建立docker組

sudo groupadd docker

將當前用戶加入docker組socket

sudo gpasswd -a ${USER} docker

從新啓動docker服務(下面是CentOS7的命令)ui

sudo service docker restart或sudo systemctl restart docker

當前用戶退出系統從新登錄this

su rootspa

su franson rest

運行docker命令

docker ps
相關文章
相關標籤/搜索