Installing Docker and using docker to install other tools.
install for WSL https://docs.docker.com/desktop/wsl/
install for centos7 https://docs.docker.com/engine/install/centos/#install-docker-engine-on-centos
install for ubuntu https://docs.docker.com/engine/install/ubuntu/
Follow the instructions to install it.
To set Docker to start automatically:
WSL:
1 | service docker start |
CentOS:
1 | sudo systemctl enable docker |
1 | docker pull mysql |
1 | docker run -p 3306:3306 --name mysql \ |
Parameter Explanation:
-p 3306:3306
: Maps the container’s 3306 port to the host’s 3306 port.-v /mydata/mysql/conf:/etc/mysql
: Mounts the configuration folder to the host.-v /mydata/mysql/log:/var/log/mysql
: Mounts the log folder to the host.-v /mydata/mysql/data:/var/lib/mysql/config.d
: Mounts the data folder to the host.-e MYSQL_ROOT_PASSWORD=root
: Initializes the password for the root user.Then check the status of the container:
1 | docker ps -a |
I run into an error of:
1 | [root@localhost vagrant]# docker ps -a |
The container didn’t start successfully and couldn’t started manually. So I checked the logs of the error info:
1 | docker logs 8adbd5efd699 |
This is because I didn’t add the conf.g
at the command line -v /mydata/mysql/conf:/etc/mysql/config.d \
Delete the stopped container
1 | docker container prune |
Logging into the container:
1 | docker exec -it mysql /bin/bash |
Add the following config to /mydata/mysql/conf/my.cnf
, create that file
1 | [client] |
Then restart docker
1 | docker restart mysql |
Set always restart by default
1 | docker update mysql --restart=always |
1 | docker pull redis |
Create directory structure and the config file
1 | mkdir -p /mydata/redis/conf |
This steps is to prevent the following command read redis.conf
as a directory not a file
Create and Run
1 | docker run -p 6379:6379 --name redis \ |
Test its usage
1 | docker exec -it redis redis-cli |
To make the data persistent, add config to the file /mydata/redis/conf/redis.conf
1 | appendonly yes |
For my WSL, I encountered an error saying I need to enable certain permissions. To solve this, run the command:
1 | sysctl vm.overcommit_memory=1 |
I use this: https://github.com/qishibo/AnotherRedisDesktopManager/releases
Set always restart by default.
1 | docker update redis --restart=always |