尝试使用没有sudo的docker后找不到sudo命令

时间:2021-08-25 02:39:29

Hello everyone & happy new year!

大家好,新年快乐!

I'm currently discovering docker. In order to avoid typing sudo with each command, I've followed the instructions on the manual page: https://docs.docker.com/engine/installation/linux/ubuntulinux/

我现在正在发现码头工人。为了避免使用每个命令键入sudo,我按照手册页上的说明进行操作:https://docs.docker.com/engine/installation/linux/ubuntulinux/

Here are the commands I've used:

这是我用过的命令:

$ sudo groupadd docker

(they said that the "docker" group already exists)

(他们说“码头工人”组已经存在)

$ sudo usermod -aG docker $USER

Not only I still have to write sudo with each docker command, but now sudo doesn't work anymore with any other command than docker.

不仅我仍然需要使用每个docker命令编写sudo,但现在sudo不再使用除docker之外的任何其他命令。

Something like sudo docker images works, but a simple sudo ls will display:

像sudo docker图像可以工作,但是会显示一个简单的sudo ls:

sudo: ls: command not found.

How can I fix this? What did I wrong?

我怎样才能解决这个问题?我错了什么?

I work on Ubuntu 16.04.

我在Ubuntu 16.04上工作。

Thank you for your help.

谢谢您的帮助。

1 个解决方案

#1


-1  

As per docker documentation, after adding the user to the docker group you must logout and later for sample testing you just try to run the hello-world without sudo.

根据docker文档,在将用户添加到docker组之后,您必须注销并稍后进行样本测试,您只需尝试运行没有sudo的hello-world。

If everything seems to be fine you can see the output from docker. If there is an issue you'll see the problem from the dockerdaemon.

如果一切似乎都很好,你可以看到docker的输出。如果出现问题,您将从dockerdaemon中看到问题。

I Hope you did all of these steps specified in docker documentation without making any mistake.

我希望您完成了docker文档中指定的所有这些步骤,而不会出现任何错误。

Now coming to your issue it doesn't affect to the sudo at all. I have installed docker in several machines including production. I never faced any issue so far. Make sure you($USER) added to docker group.

现在谈到你的问题它根本不影响sudo。我已经在几台机器中安装了docker,包括生产。到目前为止我从未遇到任何问题。确保将($ USER)添加到docker组。

I recommend to reinstall if it's not a production.

我建议重新安装,如果它不是生产。

sudo mv /var/lib/dpkg/info/docker-engine.* /tmp/

sudo mv /var/lib/dpkg/info/docker-engine.* / tmp /

sudo apt-get remove docker-engine

sudo apt-get删除docker-engine

You can do fresh Installation..

你可以做新的安装..

If you face the problem again, please attach the screen shot.

如果您再次遇到问题,请附上屏幕截图。

#1


-1  

As per docker documentation, after adding the user to the docker group you must logout and later for sample testing you just try to run the hello-world without sudo.

根据docker文档,在将用户添加到docker组之后,您必须注销并稍后进行样本测试,您只需尝试运行没有sudo的hello-world。

If everything seems to be fine you can see the output from docker. If there is an issue you'll see the problem from the dockerdaemon.

如果一切似乎都很好,你可以看到docker的输出。如果出现问题,您将从dockerdaemon中看到问题。

I Hope you did all of these steps specified in docker documentation without making any mistake.

我希望您完成了docker文档中指定的所有这些步骤,而不会出现任何错误。

Now coming to your issue it doesn't affect to the sudo at all. I have installed docker in several machines including production. I never faced any issue so far. Make sure you($USER) added to docker group.

现在谈到你的问题它根本不影响sudo。我已经在几台机器中安装了docker,包括生产。到目前为止我从未遇到任何问题。确保将($ USER)添加到docker组。

I recommend to reinstall if it's not a production.

我建议重新安装,如果它不是生产。

sudo mv /var/lib/dpkg/info/docker-engine.* /tmp/

sudo mv /var/lib/dpkg/info/docker-engine.* / tmp /

sudo apt-get remove docker-engine

sudo apt-get删除docker-engine

You can do fresh Installation..

你可以做新的安装..

If you face the problem again, please attach the screen shot.

如果您再次遇到问题,请附上屏幕截图。