Docker installs common components of mysql redis methods
- 2020-12-13 19:11:32
- OfStack
mysql docker installation
docker search mysql search
docker pull mysql:5.6 download
docker images |grep mysql To 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 description:
-p 3306:3306 : Will the container 3306 Port mapped to the host 3306 Port.
-v -v $PWD/conf:/etc/mysql/conf.d : will host under the current directory conf/my.cnf Mounted to the container /etc/mysql/my.cnf .
-v $PWD/logs:/logs : will host under the current directory logs Directory mounted to the container /logs .
-v $PWD/data:/var/lib/mysql : will host under the current directory data Directory mounted to the container /var/lib/mysql .
-e MYSQL_ROOT_PASSWORD=123456 Initialization: root The user's password.
docker ps View the image in action
Run into the container for initialization
# mysql -u root -p
# create database note;
docker installation redis
docker search redis search
docker pull redis:3.2 download
docker images redis To view
docker run -p 6379:6379 -v $PWD/data:/data -d redis:3.2 redis-server --appendonly yes run
Command description:
-p 6379:6379 : The container of 6379 Port mapped to the host 6379 port
-v $PWD/data:/data : Will host under the current directory data Mounted to the container /data
redis-server --appendonly yes : In container execution redis-server Start the command, and open redis Persistent configuration
docker ps View health
conclusion