重启虚拟机启动Docker常见问题

news/2024/7/8 7:22:27 标签: docker, 运维, linux

文章目录

  • 重启虚拟机启动Docker常见问题
    • 一、Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
    • 二、admin is not in the sudoers file. This incident will be reported.(没有这个问题请自觉跳过)
    • 三、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

重启虚拟机启动Docker常见问题

dockersock_Is_the_docker_daemon_running_2">一、Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

这个问题就很明显了,一般关闭虚拟机的话,我们的Docker也会被关掉的,这个时候,我们重启我们的虚拟机,一定要重新启动我们的Docker才行。

sudo systemctl start docker

二、admin is not in the sudoers file. This incident will be reported.(没有这个问题请自觉跳过)

如果此时报异常如下:
admin is not in the sudoers file. This incident will be reported.

那么说明你的用户并没有超级用户的权限(不能使用sudo)。此时,我们就应该把我们的用户添加到我们的用户组中。操作如下:

#切换到root用户
su

输入正确的密码后,我们切换到root用户,最前面应该是 [root 开头
在这里插入图片描述
然后我们修改我们的 sudoers 文件。

#给我们的sudoers文件添加写权限
chmod u+w /etc/sudoers
#修改我们的sudoers文件
vim /etc/audoers

在我们的 sudoers文件 中,找到 root ALL=(ALL) ALL 这一行。在他下面加入我们的用户,这里我的用户叫 admin,如果你的用户不是叫这个名字,记得改成其他的
在这里插入图片描述
修改完成,保存文件并退出。然后,去掉sudoers文件的可写权限。

#去掉sudoers文件的可写权限
chmod u-w /etc/sudoers
#退出root用户
exit

在这里插入图片描述
然后,我们看一下我们现在是否有sudo权限,输入sudo,如果此时界面显示如下,那么就说明我们的admin用户已经有sudo权限了。
在这里插入图片描述
此时,我们再使用命令

sudo systemctl start docker

便可以启动我们的Docker啦!!!

dockersock_Get_http2Fvar2Frun2Fdockersockv124containersjson_dial_unix_varrundockersock_connect_permission_denied_46">三、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

启动完docker,我们肯定要看下此时的容器是否还处于启动状态对吧。如果你在使用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

那么,就说明你的用户还没有添加到Docker组

在这里插入图片描述
此时,我们只需要使用以下命令将我们当前用户添加到Docker组就可以了:

#将我们当前用户添加到Docker组
sudo gpasswd -a $USER docker
newgrp docker
#重启一下我们的Docker
sudo systemctl restart docker

此时,我们再使用我们的docker ps命令,就可以顺利看到我们正在运行的容器啦!(当然了,由于我的虚拟机现在是刚打开,Docker也是刚打开,此时所有的容器都是停止状态)所以,如果我们要看的话,我们应该使用docker ps -a命令。
在这里插入图片描述
我们启动一下我们想要启动的容器就好啦。这里我启动一下我的容器mq。命令如下:

docker start mq

在这里插入图片描述


http://www.niftyadmin.cn/n/1733234.html

相关文章

ESP8266接温度传感器18B20时序校准

陈拓 chentuoms.xab.ac.cn 2020/06/22-2020/06/25 1. 概述 在《ESP8266_SDK发送温度数据到阿里云》 https://blog.csdn.net/chentuo2000/article/details/105592791 https://zhuanlan.zhihu.com/p/132582024 一文中我们将温度传感器DS18B20的温度数据传送到了阿里云物联网平…

RabbitMQ第四个实操小案例——DirectExchange

文章目录RabbitMQ第四个实操小案例——DirectExchangeRabbitMQ第四个实操小案例——DirectExchange DirectExchange:这种交换机的模式跟前面的Fouout(广播)不太一样,DirectExchange 会将接收到的消息根据规则路由到指定的Queue&a…

javascript面向对象技术基础(六)

http://sdcyst.javaeye.com/blog/296492作用域、闭包、模拟私有属性 先来简单说一下变量作用域,这些东西我们都很熟悉了,所以也不详细介绍。 Js代码 var sco "global"; //全局变量 function t() { var sco "local"; //函…

javascript面向对象技术基础(四)

http://sdcyst.javaeye.com/blog/288808类、构造函数、原型 先来说明一点:在上面的内容中提到,每一个函数都包含了一个prototype属性,这个属性指向了一个prototype对象(Every function has a prototype property that refers to a predefined prototype object --section8.6.…

树莓派安装Web服务器Boa和CGIC

树莓派安装Web服务器Boa和CGIC 陈拓 2020/08/01-2020/08/09 1. 树莓派换源 为了加快所需软件的下载,我们需要先换源。 首先查看系统版本:lsb_release -a修改软件更新源 /etc/apt/sources.list sudo nano /etc/apt/sources.list 在下面的语句前面加#注…

树莓派I2C通过Shell操作FDC2214

陈拓 chentuoms.xab.ac.cn 2020/07/21-2020/07/29 FDC2214是Ti公司的一款低功耗高精度的电容传感器芯片。本文讲述用树莓派Linux Shell配置和操作FDC2214,可以快速熟悉并进行原型开发。 1. 树莓派换源 为了加快所需软件的下载,我们需要先换源。 首先查…

界面渐变特效 -- CSS实现 -- 兼容IE8

特别注意:里面的RGB颜色值必须要全写,不能使用缩写。左右:background: -webkit-gradient(linear, 0 0, 0 100%, from(#80c1e7), to(#213c7c)); background: -webkit-linear-gradient(left, #80c1e7, #213c7c); background: -moz-linear-g…

javascript面向对象技术基础(二)

数组 我们已经提到过,对象是无序数据的集合,而数组则是有序数据的集合,数组中的数据(元素)通过索引(从0开始)来访问,数组中的数据可以是任何的数据类 型.数组本身仍旧是对象,但是由于数组的很多特性,通常情况下把数组和对象区别开来分别对待(Throughout this book, objects and…