1. Docker mounts the local directory Docker can support mounting a directory on the host into the image. Run in interactive mode
Background operation
Through the -v parameter, the path before the colon is the host directory, which must be an absolute path, and the path after the colon is the path mounted in the image. Now the files in the host machine can be shared in the image. The default mount path permissions are read and write. If you specify it as read-only, you can use: ro
2. Docker data volume container Docker also provides an advanced usage. It's called a data volume. Data volume: "It is actually a normal container that is specifically used to provide data volumes for other containers to mount." It feels like a data mount information defined by a container. Other container startups can directly mount the mount information defined in the data volume container. Example:
Create a normal container. Use --name to assign a name to it (if not specified, a random name will be generated). Create a new container to use this data volume.
--volumes-from is used to specify which volume to mount the data from. In this way, the /usr/Downloads directory in the newly created container will be synchronized with the host directory /home/dock/Downloads Supplementary knowledge: Linux series - Docker realizes container configuration localization by mounting data volumes to MySQL Pull the mysql image
Create and run the mysql container (mount the data volume to mysql) docker run -p 3306:3306 --name mysql \ -v /usr/local/docker/mysql/conf:/etc/mysql \ -v /usr/local/docker/mysql/logs:/var/log/mysql \ -v /usr/local/docker/mysql/data:/var/lib/mysql \ -e MYSQL_ROOT_PASSWORD=123123 \ -d mysql After executing the above instructions, the MySQL container cannot be started. The error reported is that there is an error in reading the file /var/lib/mysql-file. ###############Solve the problem that mysql cannot be started above################ Temporarily associate the local configuration directory /usr/local/docker/mysql/conf with the app folder in the container (the container configuration directory cannot be directly associated. Due to file synchronization reasons, the container configuration directory will be empty and the container cannot be started). Later, the container configuration file will be copied to ./conf to achieve the purpose of copying the container file.
Enter the mysql container
Copy all the files in the etc/mysql directory to the app directory. Since local synchronization was done before, you can see the mysql configuration file in the local folder ./conf
Deleting a container
Create a new container to synchronize the local MySQL folder with the MySQL-related files in the container. docker run -p 3306:3306 --name mysql \ -v /usr/local/docker/mysql/conf:/etc/mysql \ -v /usr/local/docker/mysql/logs:/var/log/mysql \ -v /usr/local/docker/mysql/data:/var/lib/mysql \ -e MYSQL_ROOT_PASSWORD=123123 \ -d mysql The above Docker mounts local directories and data volume container operations are 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:
|
<<: 56 practical JavaScript tool functions to help you improve development efficiency
>>: CSS and HTML and front-end technology layer diagram
1. Overview of modules and instructions used to l...
Method 1: Use Google advanced search, for example...
npm installation tutorial: 1. Download the Node.j...
Sometimes it is slow to download large network fi...
According to data analysis company Net Market Sha...
First look at the effect diagram: The complete co...
In Docker's design, a container runs only one...
There are two files a.htm and b.htm. In the same d...
Table of contents Preface know Practice makes per...
This article describes the sql_mode mode in MySQL...
As the platform continues to grow, the project...
Download image docker pull mysql:5.7 docker pull ...
Table of contents 1. beforeCreate and created fun...
** Detailed graphic instructions for installing y...
Table of contents Preface 1. Trigger Overview 2. ...