普通用户没有docker,非root用户如何安装docker?

I am using a CentOS 6.9 system of High performance computation platform and I wanna use docker with non-root user. Is there a method that I can build docker from source and do not need root privilege?

解决方案

This shouldn't be possible as it would be a major security concern.

When docker is installed on a machine, users with docker access (not necessarily root) can start containers. In particular, they can start containers in priviliged mode, giving the container access to all host devices.

More importantly, A user with access to docker can mount directories owned exclusively by machine root. Since by default, a root user inside the container will have access to mounted root-owned directories inside the container, this will allow any Docker container started by a non-root user to access critical machine stuff.

Therefore, the sequence of having a non-root user install Docker and start containers should not be allowed as it can compromise the whole machine.

Check this explicit comment from one of the docker maintainers.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在 Ubuntu 22.04 中,如果你不想使用 root 用户安装 Docker,可以按照以下步骤进行: 1. 在另一台联网的机器上,下载 Docker 的 deb 包和依赖包。可以从 Docker 的官方网站下载对应版本的 deb 包和依赖包,也可以使用 wget 命令下载。 例如,如果要安装 Docker 20.10.8 版本,可以使用以下命令下载对应的 deb 包和依赖包: ``` mkdir docker cd docker wget https://download.docker.com/linux/ubuntu/dists/hirsute/pool/stable/amd64/containerd.io_1.4.9-1_amd64.deb wget https://download.docker.com/linux/ubuntu/dists/hirsute/pool/stable/amd64/docker-ce-cli_20.10.8~3-0~ubuntu-hirsute_amd64.deb wget https://download.docker.com/linux/ubuntu/dists/hirsute/pool/stable/amd64/docker-ce-rootless-extras_20.10.8~3-0~ubuntu-hirsute_amd64.deb wget https://download.docker.com/linux/ubuntu/dists/hirsute/pool/stable/amd64/docker-ce_20.10.8~3-0~ubuntu-hirsute_amd64.deb ``` 2. 将下载的 deb 包和依赖包复制到目标机器上。 可以使用 scp 命令将文件复制到目标机器上,例如: ``` scp *.deb user@remote:/path/to/folder ``` 其中,user 是目标机器上的用户名,remote 是目标机器的 IP 地址或域名,/path/to/folder 是目标机器上的文件夹路径。 3. 在目标机器上安装依赖包。 使用以下命令安装依赖包: ``` sudo dpkg -i containerd.io_1.4.9-1_amd64.deb docker-ce-cli_20.10.8~3-0~ubuntu-hirsute_amd64.deb docker-ce-rootless-extras_20.10.8~3-0~ubuntu-hirsute_amd64.deb docker-ce_20.10.8~3-0~ubuntu-hirsute_amd64.deb ``` 如果出现依赖关系错误,可以使用以下命令修复: ``` sudo apt-get install -f ``` 4. 将 root 用户添加到 docker 用户中。 使用以下命令将当前用户添加到 docker 用户中: ``` sudo usermod -aG docker $USER ``` 其中,$USER 是当前用户名。 5. 重新登录或重启系统。 为了让用户变化生效,需要重新登录或重启系统。 6. 验证 Docker 是否安装成功。 使用以下命令验证 Docker 是否安装成功: ``` docker run hello-world ``` 如果输出以下信息,说明 Docker 安装成功: ``` Hello from Docker! This message shows that your installation appears to be working correctly. ... ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值