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

Introduction and use of Javascript generator

What is a generator? A generator is some code tha...

How to elegantly implement WeChat authorized login in Vue3 project

Table of contents Preface Prepare Implementation ...

Nginx server https configuration method example

Linux: Linux version 3.10.0-123.9.3.el7.x86_64 Ng...

Historical Linux image processing and repair solutions

The ECS cloud server created by the historical Li...

Introduction to the use of MySQL official performance testing tool mysqlslap

Table of contents Introduction Instructions Actua...

How to implement digital paging effect code and steps in CSS

A considerable number of websites use digital pagi...

JS implements user registration interface function

This article example shares the specific code of ...

Why Google and Facebook don't use Docker

The reason for writing this article is that I wan...

The pitfall record of case when judging NULL value in MySQL

Table of contents Preface Mysql case when syntax:...

ReactRouter implementation

ReactRouter implementation ReactRouter is the cor...

JDBC Exploration SQLException Analysis

1. Overview of SQLException When an error occurs ...

Summary of several implementations of returning to the top in HTML pages

Recently, I need to make a back-to-top button whe...

Solution to the Chinese garbled characters problem in MySQL under Ubuntu

Find the problem I have been learning Django rece...