切换到Docker根用户 [英] Switch to Docker Root User

查看:74
本文介绍了切换到Docker根用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Docker,并且在Docker CLI上执行任何命令之前,我需要切换到使用该命令使用的root用户

I am working on Docker and before i execute any command on Docker CLI , I need to switch to root used using the command

sudo su-root

谁能告诉我为什么我们需要切换到 root 用户才能在Docker Engine上执行任何操作?

Can anyone please tell me why we need to switch to root user to perform any operation on Docker Engine?

推荐答案

您不需要为docker cli命令切换到 root ,通常将您的用户添加到docker

you don't need to switch to root for docker cli commands and it is common to add your user to the docker group

sudo groupadd docker
sudo usermod -aG docker $USER

请参阅:https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user

docker以root身份运行的原因:

the reason why docker is run as root:

Docker守护程序绑定到Unix套接字而不是TCP端口.默认情况下,Unix套接字由用户root拥有,其他用户只能使用sudo访问它.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 only access it using sudo. The Docker daemon always runs as the root user.

这篇关于切换到Docker根用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆