When you use the docker command for the first time, you will be prompted for permission issues.
Solution:1. Use sudo to obtain root privileges; Second, add the current user to the docker user group; sudo groupadd docker #Add docker user group sudo gpasswd -a $USER docker #Add the logged in user to the docker user group newgrp docker #Update user group docker ps #Test whether the docker command can be used normally with sudo Supplement: Problem and solution of root user being unable to log in when deploying mysql with docker Today, when using the mysql:5.7 docker image, I found that I could not log in using the root user after starting the container. Here are the steps: 1. Pull the mysql5.7 image$ docker pull mysql:5.7 2. Create a bridge$docker network create -d bridge blog_network 3. Run the mysql containerdocker container run -it --rm --name mysql --network blog_network -v $PWD/data/myscript/:/docker-entrypoint-initdb.d/ --env MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7 4. Enter the container$ docker exec -it mysql bash #mysql -u root -p The password 123456 set in step 3 returns the result: Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 5. The solution is as followsStep 2: Run the container command and modify it as follows: $ docker container run -it --detach --name mysql --network blog_network -p 3306:3306 -v $PWD/data/myscript/:/docker-entrypoint-initdb.d/ --env MYSQL_RANDOM_ROOT_PASSWORD=yes mysql:5.7 $ docker container logs mysql| grep 'GENERATED ROOT PASSWORD: ' | awk -F': ' '{print $2}' A string will be returned, which is the actual password of our root user: log in with this password and then change the root user password. ooli0OhMoo1Ieg1CeiYieSohleeVi1oh $mysql -u root -p After entering mysql using the above password, you need to change the password. mysql>update mysql.user set authentication_string=password('newpassword') where user='root'; mysql>flush privileges; mysql>exit As shown in the figure: 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:
|
<<: Various transformation effects of HTML web page switching
>>: Media query combined with rem layout in CSS3 to adapt to mobile screens
Table of contents Scenario Code Implementation Su...
Preface Recently, when working on a high-availabi...
Step 1: Enter the directory: cd /etc/mysql, view ...
Table of contents What is pre-analysis? The diffe...
Table of contents background 1. The query conditi...
Table of contents introduce Key Features Effect d...
Problem description: For example, the content of ...
This article describes the MySQL multi-table join...
Preface This article mainly introduces how to sta...
We all know that we need to understand the proper...
Preface: The group by function retrieves the firs...
Table of contents 1. Introduction 2. Use 1. Diffe...
Table of contents Overview 1. Define store.js 2. ...
This article mainly introduces the implementation...
First, let’s understand what MySQL is? MySQL is a...