安装docker
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
sudo mkdir -p /etc/docker
echo '{"registry-mirrors":["https://reg-mirror.qiniu.com/"]}' > /etc/docker/daemon.json
网易:https://hub-mirror.c.163.com/
容器自启
docker container update --restart=always 容器名字
安装mysql
mkdir -p /mydata/mysql/conf
vi /mydata/mysql/conf/my.cnf
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
init_connect='SET collation connection = utf8mb4_unicode_ci'
init_connect='SET NAMES utf8mb4'
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
docker pull mysql:5.7
docker run -p 3306:3306 --name mysql
-v /mydata/mysql/log:/var/log/mysql
-v /mydata/mysql/data:/var/lib/mysql
-v /mydata/mysql/conf:/etc/mysql
-e MYSQL_ROOT_PASSWORD=root
-d mysql:5.7
安装redis
mkdir -p /mydata/redis/conf
touch /mydata/redis/conf/redis.conf
vi /mydata/redis/conf/redis.conf
# 添加如下内容
appendonly yes
docker pull redis
docker run -p 6379:6379 --name redis
-v /mydata/redis/data:/data
-v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf
-d redis redis-server /etc/redis/redis.conf
docker exec -it redis redis-cli
安装nginx
mkdir -p /mydata/nginx 等等目录,需要提前创建
docker run
--name nginx
-p 80:80
-v /mydata/nginx/nginx.conf:/etc/nginx/nginx.conf
-v /mydata/nginx/log:/var/log/nginx
-v /mydata/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf
-d nginx