首頁>Server>source

我刚刚在Ubuntu 20.04上安裝了docker,並註意到docker必须以sudo執行。

[email protected]:~$ docker ps
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.24/containers/json: dial unix /var/run/docker.sock: connect: permission denied
[email protected]:~$ 
[email protected]:~$ sudo docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[email protected]:~$

找到了本教程並尝試遵循它

Step 2 — Executing the Docker Command Without Sudo (Optional)

https ://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04

[email protected]:~$ sudo usermod -aG docker ${USER}
[email protected]:~$ su - ${USER}
Password: 
[email protected]:~$

這似乎很好。

[email protected]:~$ id -nG
wolf docker
[email protected]:~$ 
[email protected]:~$ docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[email protected]:~$

但是,当我打開另一个终端時,它不再起作用.我收到与上述類似的錯誤。

最新回復
  • 5月前
    1 #

    重新啟動應该可以解決問题

  • 帶有隨機日期的Docker容器
  • rhel6:百胜更新清除已掛起