Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to prevent sudo from using the docker command

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to avoid sudo using the docker command, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Background

Docker is an advanced LXC-based container engine from PaaS supplier dotCloud. The source code is hosted on GitHub, developed based on the Go language and open source in accordance with the Apache 2.0 protocol. Docker provides a way to deploy software automatically in a secure and repeatable environment, and its emergence is a prelude to a change in the way products are released based on cloud computing platforms.

Sudo is one of the most important commands necessary for Linux system administrators or advanced users. And because you are using sudo to install docker, it can cause a problem. In the case of ordinary users logging in, sudo must be added when using docker images, so how to make docker sudo-free and still available? So began to search for a solution.

Straighten out the problem

The following error occurs when using docker images as a normal user:

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.26/images/json: dial unix / var/run/docker.sock: connect: permission denied

You can take a look at Dudu and finally inform us of the question of authority. Then there are about three data in the linux file permissions, drwxrwxrwx.

The first is d, which means that the file is a folder

The first three, the middle three and the last three represent the primary authority, group authority and other rights respectively.

As shown in the figure, the third column and the fourth column represent the owner and group of the document, respectively.

The above figure shows the permissions of the error report file. You can see that the owner is root, the permission is rw, readable and writable; the group is docker, and the permission is rw, which is readable and writable. If you want the current user to read the file directly, then we can add it to the docker membership group for the current user.

If you don't already have a docker group, add one:

Sudo groupadd docker

Add the user to the group. Then log out and log back in and take effect.

Sudo gpasswd-a ${USER} docker

Restart the docker service

Sudo service docker restart

Switch the current session to a new group or restart the X session

Newgrp-docker

Note: the last step is necessary, otherwise because the groups command gets the cached group information, the group information just added does not take effect, so there is also an error in the execution of docker images.

The above is all the contents of this article entitled "how to avoid sudo using docker commands". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report