Using docker command does not require sudo

Using docker command does not require sudo

Because the docker daemon needs to bind to the host's Unix socket instead of a normal TCP port, and the owner of the Unix socket is the root user, other users can perform related operations only by adding the sudo option before the command.

If you don’t want to type sudo every time you use the docker command, you can configure it as follows.

1. Create a docker group

$ sudo groupadd docker

2. Add the current user to the docker group

$ sudo usermod -aG docker $USER

3. Log out and log back into the shell

4. Verify that the docker command can run

$ docker run hello-world

Additional knowledge: Docker image acceleration

After installing Docker, the next step is to have fun, but the actual situation is not pleasant

Because the default image source of Docker is abroad, due to the special network reasons in China, it is often slow to access or completely inaccessible. Fortunately, there are similar image sources available in China. I use the image source provided by daocloud, and the experience is pretty good.

Conveniently, they provide a script to modify the mirror source with one click. The specific commands are as follows:

curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://01393398.m.daocloud.io

After executing the above command, the default image source of docker points to the image warehouse of daocloud. At this time, you need to restart the docker service to take effect.

sudo systemctl restart docker.service

Try to pull an image

$ docker pull busybox

If the image is downloaded successfully, it means that the above changes have taken effect.

Reference official website

The above operation of using docker command without typing sudo is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • How to execute Docker commands without sudo
  • How to use docker commands without sudo
  • Solve the problem that Docker must use sudo operations

<<:  Steps to install MySQL using Docker under Linux

>>:  JavaScript to implement drop-down list selection box

Recommend

Detailed configuration of mysql8.x docker remote access

Table of contents Environmental conditions Errors...

React passes parameters in several ways

Table of contents Passing parameters between pare...

What kinds of MYSQL connection queries do you know?

Preface If the query information comes from multi...

Some settings of Div about border and transparency

frame: Style=”border-style:solid;border-width:5px;...

React mouse multi-selection function configuration method

Generally, lists have selection functions, and si...

Introduction to keyword design methods in web design

Many times, we ignore the setting of the web page ...

Example of how to install nginx to a specified directory

Due to company requirements, two nginx servers in...

JavaScript array reduce() method syntax and example analysis

Preface The reduce() method receives a function a...

Solution for mobile browsers not supporting position: fix

The specific method is as follows: CSS Code Copy ...

Solve the problem of managing containers with Docker Compose

In Docker's design, a container runs only one...

Mac installation mysqlclient process analysis

Try installing via pip in a virtual environment: ...

Summary of MySQL's commonly used database and table sharding solutions

Table of contents 1. Database bottleneck 2. Sub-l...

How to use & and nohup in the background of Linux

When we work in a terminal or console, we may not...