Solve the problem that Docker must use sudo operations

Solve the problem that Docker must use sudo operations

The steps are as follows

1. Create a docker group: sudo groupadd docker

2. Add the current user to the docker group: sudo gpasswd -a ${USER} docker

3. Restart the service: sudo service docker restart

4. Refresh docker members: newgrp - docker

[Note]: This has been tested on Ubuntu, not on other Linux systems.

Supplement: Docker installation under Linux, and configuration to execute Docker without sudo command

Install

Execute the following command

wget -qO- https://get.docker.com/ | sh

Execute docker without sudo command

Why do we need to create a docker user group?

The Docker daemon binds to a unix socket, not a TCP port. The default owner of this socket is root, and other users can use the sudo command to access this socket file. For this reason, the Docker service process runs as the root account.

To avoid having to enter sudo every time you run a docker command, you can create a docker user group and add the corresponding users to this group. When the docker process starts, the socket is set to be readable and writable by users of the docker group. In this way, any user in the docker group can directly execute docker commands.

Warning: This dockergroup is equivalent to the root account. For more details, please refer to this article: Docker Daemon AttackSurface .

1 Log in to the system using an account with sudo privileges.

2 Create a docker group and add the corresponding users to this group.

sudo usermod -aG docker your_username

3 Log out and then log in again for the permissions to take effect.

4 Confirm that you can run docker commands directly.

$ docker run hello-world

The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. If there are any mistakes or incomplete considerations, please feel free to correct me.

You may also be interested in:
  • Using docker command does not require sudo
  • How to execute Docker commands without sudo
  • How to use docker commands without sudo

<<:  Solution to MySQL replication failure caused by disk fullness

>>:  Mini Program Custom TabBar Component Encapsulation

Recommend

Vue interpretation of responsive principle source code analysis

Table of contents initialization initState() init...

How to use watch listeners in Vue2 and Vue3

watch : listen for data changes (change events of...

JS+Canvas draws a lucky draw wheel

This article shares the specific code of JS+Canva...

Apache Spark 2.0 jobs take a long time to finish when they are finished

Phenomenon When using Apache Spark 2.x, you may e...

Detailed explanation of the installation steps of the MySQL decompressed version

1. Go to the official website: D:\mysql-5.7.21-wi...

Installation steps of mysql under linux

1. Download the mysql tar file: https://dev.mysql...

Detailed analysis of binlog_format mode and configuration in MySQL

There are three main ways of MySQL replication: S...

Websocket+Vuex implements a real-time chat software

Table of contents Preface 1. The effect is as sho...

Implementation code of using select to select elements in Vue+Openlayer

Effect picture: Implementation code: <template...