When I was writing a project yesterday, I needed to use the derivative version of MySQL, Percona, so I wanted to use Docker to install it. As a result, I stepped on the pit all night, and finally solved it this morning. Now record it here. After pulling, enter docker images to view all images, and the display is normal: Then I create a container with the following command (do not use line breaks when executing): docker create --name percona -v /data/mysql-data:/var/lib/mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root percona:lates This command means that I create a container named percona, then map my local /data/mysql-data directory to the /var/lib/mysql directory in the docker container and specify port 3306, then set the database root user password to root, and the last percona:latest specifies the version I pulled above. Because the database in the docker container is just a mirror, it can be understood that it does not really exist. The purpose of mapping it to my local directory is that the data stored in the /var/lib/mysql directory by docker can be synchronized and stored in my local /data/mysql-data directory. This ensures that the data is not lost and facilitates my local operations. If you don't understand the command parameters, you can read the official documentation or search for a docker video tutorial, which has explanations. Then I start this container, docker start percona. After starting, query all running containers docker ps, and then there is a problem: It is empty, that is, no running containers are found... Then I checked all containers, including running and non-running ones. docker ps -a shows the following: It turns out that the port was not bound successfully, so it did not run! It automatically exited every time it was run. At this time, I checked the docker logs and entered the command docker logs container id, which showed the following: Note: 71 here is the first two digits of the container_id of this container. Docker supports this simplified writing. The log error says that I do not have permission to create and write to the /var/lib/mysql directory in the container. docker run -ti --rm --entrypoint="/bin/bash" percona -c "whoami && id" This command is used to view the owner of the container, which is displayed as: Then enter (no line breaks): docker run -ti --rm -v /data/mysql-data:/var/lib/mysql --entrypoint="/bin/bash" percona -c "ls -la /var/lib/mysql" This command is used to view the owner of this directory when mapping a local data volume. This is the reason. This is why when the mysql user accesses the directory in docker, a permission error is reported! Because the owner of the local mapping directory is the root user, and the owner of the /var/lib/mysql directory in the docker container is the mysql user, with a uid of 999! The problem is solved! I wasted a whole night. I have to say that I need to deepen my knowledge of Linux permission control! This is the end of this article about the pitfalls of directory permissions when Docker creates containers. For more information about directory permissions when Docker creates containers, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: MySQL 8.0 New Features: Hash Join
>>: Solution to win10 without Hyper-V
Table of contents 1- Error details 2-Single Solut...
Today I happened to be helping a friend move his ...
This article shows you how to use CSS to create a...
Inserting images into HTML requires HTML tags to ...
Docker installs MySQL version 8.0.20 for your ref...
Preface Note: The test database version is MySQL ...
Preface: Docker is an open source application con...
1. dhtmlxTree dHTMLxTree is a feature-rich Tree M...
This article is mainly to take you to quickly und...
Table of contents 01 Introduction to Atomic DDL 0...
Table of contents 1. Basic Example 2. Set the sco...
The specific code for implementing skinning with ...
The role of the interface: Interface, in English:...
There are too many articles about xhtml+css websi...
Example Usage Copy code The code is as follows: &l...