普通用户权限运行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 only access it using `sudo`. The Docker daemon always runs as the `root` user.

If you don’t want to preface the docker command with sudo, create a Unix group called docker and add users to it. When the Docker daemon starts, it creates a Unix socket accessible by members of the docker group.

普通用户执行权限添加

  1. 创建docker用户组
    sudo groupadd docker
  2. 添加你想用普通用户权限的用户名到docker用户组
    sudo usermod -aG docker $USER
    
  3. 系统重启后就可以使用普通用户权限执行docker, 如果不想重启,可以使用下面的命令更新并激活组权限
    newgrp docker
    
  4. 验证设置是否成功
    docker run hello-world
    
    如果出现下面错误提示,建议重启电脑:
    WARNING: Error loading config file: /home/user/.docker/config.json -
    stat /home/user/.docker/config.json: permission denied
    
本作品采用《CC 协议》,转载必须注明作者和本文链接
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!