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 explanation of the properties and functions of Vuex

Table of contents What is Vuex? Five properties o...

React gets input value and submits 2 methods examples

Method 1: Use the target event attribute of the E...

Windows 10 1903 error 0xc0000135 solution [recommended]

Windows 10 1903 is the latest version of the Wind...

Mysql sorting and paging (order by & limit) and existing pitfalls

Sorting query (order by) In e-commerce: We want t...

XHTML no longer uses some obsolete elements in HTML

When we do CSS web page layout, we all know that i...

Example code for implementing image adaptive container with CSS

There is often a scenario where the image needs t...

How to implement MySQL master-slave replication based on Docker

Preface MySQL master-slave replication is the bas...

How to handle forgotten passwords in Windows Server 2008 R2

What to do if you forget Windows Server 2008R2 So...

Introduction and usage examples of ref and $refs in Vue

Preface In JavaScript, you need to use document.q...

How to download excel stream files and set download file name in vue

Table of contents Overview 1. Download via URL 2....