How to install common components (mysql, redis) in Docker

How to install common components (mysql, redis) in Docker

Docker installs mysql

docker search mysql Search docker pull mysql:5.6 Download docker images |grep mysql View docker run -p 3306:3306 --name mysql_docker -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6 Run command instructions:
-p 3306:3306: Maps port 3306 of the container to port 3306 of the host.
-v -v $PWD/conf:/etc/mysql/conf.d: Mount conf/my.cnf in the current directory of the host to /etc/mysql/my.cnf in the container.
-v $PWD/logs:/logs: mounts the logs directory under the current directory of the host to the /logs of the container.
-v $PWD/data:/var/lib/mysql : Mount the data directory under the current directory of the host to /var/lib/mysql of the container.
-e MYSQL_ROOT_PASSWORD=123456: Initialize the root user's password.
docker ps View the running of the image and enter the container to initialize it after running# mysql -u root -p
# create database note;

Docker installation redis

docker search redis Search docker pull redis:3.2 Download docker images redis View docker run -p 6379:6379 -v $PWD/data:/data -d redis:3.2 redis-server --appendonly yes Run command instructions:
-p 6379:6379: Map the container's port 6379 to the host's port 6379 -v $PWD/data:/data: Mount the data in the current directory on the host to the container's /data
redis-server --appendonly yes: Execute the redis-server startup command in the container and turn on the redis persistence configuration docker ps to view the running status

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • Architecture and component description of docker private library Harbor
  • Detailed explanation of the union file system of Docker core components

<<:  Vue+Bootstrap realizes a simple student management system

>>:  View the frequently used SQL statements in MySQL (detailed explanation)

Recommend

Mysql database design three paradigm examples analysis

Three Paradigms 1NF: Fields are inseparable; 2NF:...

How to quickly modify the table structure of MySQL table

Quickly modify the table structure of a MySQL tab...

Implementation of Docker packaging image and configuration modification

I have encountered many problems in learning Dock...

Several scenarios for using the Nginx Rewrite module

Application scenario 1: Domain name-based redirec...

50 Super Handy Tools for Web Designers

Being a web designer is not easy. Not only do you...

Detailed examples of variable and function promotion in JavaScript

js execution Lexical analysis phase: includes thr...

Quickly solve the Chinese input method problem under Linux

Background: I'm working on asset reporting re...

React diff algorithm source code analysis

Table of contents Single Node Diff reconcileSingl...

Several CSS3 tag shorthands (recommended)

border-radius: CSS3 rounded corners Syntax: borde...

A brief discussion on the differences between FTP, FTPS and SFTP

Table of contents Introduction to FTP, FTPS and S...

JavaScript to implement random roll call web page

JavaScript writes a random roll call webpage for ...

Implementing password box verification information based on JavaScript

This article example shares the specific code of ...

Detailed explanation of three ways to connect Docker containers to each other

There are three ways to interconnect and communic...