Docker使用非root用户

通常我们使用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 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.

下面是使用非root用户操作的步骤

创建docker组

sudo groupadd docker

将当前用户加入docker组

sudo gpasswd -a ${USER} docker

重新启动docker服务(下面是CentOS7的命令)

sudo systemctl restart docker

当前用户退出系统重新登陆

运行docker命令

docker ps
时间: 2024-08-25 19:41:13

Docker使用非root用户的相关文章

Docker安全--关于Docker使用root与非root用户的场景中的容器与host中的执行用户的研究

/************************************************* * Author : Samson * Date : 08/15/2015 * Test platform: * gcc 4.8.2 * GNU bash, 4.3.11(1)-release (x86_64-pc-linux-gnu) * ***********************************************/ 结论 实际进行测试的Dockerfile是shadowso

Linux 下非root用户使用docker

Linux 下非root用户使用docker 通常我们使用linux系统的时候,最好是不要直接使用root账号,但是使用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 access it wi

Linux下非root用户安装软件的一般流程:

1. 获取源代码,一般是wget方式,ubuntu可以使用apt-get source来获取源代码. 2. 解压源代码,一般使用tar -zxvf xxx.tar.gz即可 3. 切换到解压后的目录,运行 ./configure.其选项可以通过 ./configure –help来获取,非root用户下最重要的应该是定义安装目录,即应该定义 ./configure –prefix=/path/to/bin, 对于一些依赖库,可能还需要使用 ./configure  –prefix=xxx –wi

Linux下非root用户安装软件

下面简要说一下Linux下非root用户安装软件的一般流程:1. 获取源代码,一般是wget方式,ubuntu可以使用apt-get source来获取源代码.2. 解压源代码,一般使用tar -zxvf xxx.tar.gz即可3. 切换到解压后的目录,运行 ./configure.其选项可以通过 ./configure –help来获取,非root用户下最重要的应该是定义安装目录,即应该定义 ./configure –prefix=/path/to/bin, 对于一些依赖库,可能还需要使用

通过非root用户访问VNC

我采用的是realvnc5.3.2.对于非root用户通过vnc访问linux桌面,网络上绝大数文章都是说要去配置/etc/sysconfig/vncservers.但安装完realvnc5.3.2之后并没有这个文件.但注意,在安装realvnc5.3.2之后,会在linux(笔者采用的是Red Hat Enterprise)桌面的右上方出现vnc的图标(见下图红色圈住部分),右击这个图标,选择第二项“Option”,择“user & permissions ”,然后选择"add&quo

linux下非root用户如何修改root权限的文件

在linux下会出现把一些配置文件参数配错.root密码忘记等导致系统无法启动或进入root的窘迫境地,本文以redhat  enterprise linux server 6.4为例介绍root身份修改root权限配置文件的参数后,root无法登录,然后通过linux的rescue模式改回配置文件,巧妙以非root身份修改了root权限的文件的解决方案. 首先,插入linux安装盘重启系统,等到引导进入安装会话,上下移动方向键,选rescue installed system: 第二,进入修复

MHA+非root用户SSH等效性配置

环境:CentOS5.8 MySQL5.5.17 实验:搭建MHA高可用架构(非root用户SSH等效性配置)SSH等效性用户配置的是:concert  端口:1314 MHA配置文件 [[email protected] mha]$ more /etc/masterha_default.cnf [server default] user          = root password      = mysql_admin ssh_user      = concert ssh_port   

非root用户启动nginx master process

nginx启动进程可以在conf里指定user(user  work;)但是这个只有在用root启动的情况有意义,如果要是用非root用户比如www-data启动nginx,则需要注释掉use work:这行 /usr/sbin/nginx  -c /etc/nginx/nginx.conf 这样 www-data  41121      1  0 19:40 ?        00:00:00 nginx: master process /usr/sbin/nginx -c /etc/ngin

linux下非root用户的sudo问题

linux下的root用户是个超级管理员,一般是不用这个用户登录进行操作的,但有时候需要root权限,又不想切换用户的话可以使用sudo命令.但是不是所有的用户都可以使用sudo命令的. 首先可能会遇到下面的提示: ××× is not in the sudoers file.  This incident will be reported. 解决办法: 1.修改/etc/sudoers 文件 #su - #chmod u+w /etc/sudoers 在 root    ALL=(ALL)