docker各容器安装
2024年11月13日大约 1 分钟
目前安装的是Docker version 27.3.1, build ce12230
使用绝对路径的目的是,在任意目录下执行命令都可以启动和映射对应的数据到本地
mysql
docker pull mysql:8.0.20
mkdir -p /root/docker-data/mysql/conf
mkdir -p /root/docker-data/mysql/logs
mkdir -p /root/docker-data/mysql/data
启动:
docker run \
-p 3308:3306 \
--name n_mysql8 \
--privileged=true \
-v /root/docker-data/mysql/conf:/etc/mysql/conf.d \
-v /root/docker-data/mysql/logs:/var/log/mysql \
-v /root/docker-data/mysql/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=queque123 \
-d mysql:8.0.20
https://www.cnblogs.com/sheseido/p/12708864.html
适用于编排
https://www.cnblogs.com/liugp/p/17441936.html
开启远程连接:
进入mysql8容器:
docker exec -it n_mysql8 /bin/bash
连接数据库,输入密码
mysql -u root -p
创建远程连接用户
# 创建远程连接
create user 'umami-uu'@'%' identified by 'wapCatDog.' PASSWORD EXPIRE NEVER;
grant all privileges on *.* to 'umami-uu'@'%';
flush privileges;
参考:https://www.cnblogs.com/lfxx/p/17522877.html
https://blog.csdn.net/u014282578/article/details/127920419
https://developer.aliyun.com/article/1436396
定制版本:
docker run \
-p 3308:3306 \
--name n_mysql8 \
--privileged=true \
-v /root/docker-data/mysql/conf:/etc/mysql/conf.d \
-v /root/docker-data/mysql/logs:/var/log/mysql \
-v /root/docker-data/mysql/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=queque123 \
-e MYSQL_USER: umami-uu
-e MYSQL_PASSWORD: queque
-d mysql:8.0.20
redis
docker pull redis:latest
启动
docker run --name n_redis \
-p 8379:6379 \
-v /root/docker-data/redis/redis.conf:/etc/redis/redis.conf \
-v /root/docker-data/redis/data:/data \
-d redis --requirepass 121212 \
--appendonly yes
nginx
docker pull nginx:1.25.1
启动:
docker run -d \
--restart always \
--name n_nginx \
-p 80:80 \
-v /root/docker-data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v /root/docker-data/nginx/conf/conf.d:/etc/nginx/conf.d \
-v /root/docker-data/nginx/log:/var/log/nginx \
-v /root/docker-data/nginx/html:/usr/share/nginx/html \
nginx:1.25.1
uptime
docker pull louislam/uptime-kuma:1
创建目录:
mkdir -p /root/docker-data/uptime-kuma
启动:
docker run -d \
--restart=always \
--name uptime-kuma \
-p 7001:3001 \
-v /root/docker-data/uptime-kuma:/app/data \
louislam/uptime-kuma:1
nginx proxy manager配置uptime,注意点是,使用代理,需要启动 websocket
https://github.com/louislam/uptime-kuma/wiki/Reverse-Proxy#nginx
watch:
https://www.youtube.com/watch?app=desktop&v=rj7DZdWMK2k&t=1700s
docker compose方式启动: