一. Docker 安装
1.安装流程
centos:https://docs.docker.com/engine/install/centos/
ubuntu:https://docs.docker.com/engine/install/ubuntu/
2.配置镜像加速服务
阿里云搜索容器镜像服务
二. Docker 部署 solo
-
拉取 solo 镜像
docker pull b3log/solo
-
Docker 部署 mysql
docker pull mysql docker run -id --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql docker cp mysql:/var/lib/mysql /opt/mysql docker cp mysql:/etc/mysql/conf.d /opt/mysql docker cp mysql:/etc/my.cnf /opt/mysql docker rm -f msyql docker run -id --name mysql -p 3306:3306 -v /opt/mysql/mysql:/var/lib/mysql -v /opt/mysql/conf.d:/etc/mysql/conf.d -e mysql_root_password=123456 mysql
-
进入 mysql 容器创建数据库以及数据表
docker exec -it 容器id /bin/bash #手动建库 create database solo default character set utf8mb4 collate utf8mb4_general_ci; create user 'root'@'127.0.0.1' identified by '123456'; grant all privileges on *.* to 'root'@'127.0.0.1'; flush privileges;
-
启动 solo 容器
docker run --detach -v /opt/solo/markdowns/:/opt/solo/markdowns/ --name solo --network=host --env RUNTIME_DB="MYSQL" --env JDBC_USERNAME="root" --env JDBC_PASSWORD="123456" --env JDBC_DRIVER="com.mysql.cj.jdbc.Driver" --env JDBC_URL="jdbc:mysql://127.0.0.1:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true" b3log/solo --listen_port=8080 --server_scheme=http --server_host=localhost --server_port= --static_server_scheme=https --static_server_host=cdn.jsdelivr.net --static_server_port= --static_path=/gh/88250/solo/src/main/resources
Nginx 反代
-
docker 部署 nginx
#拉取镜像 docker pull nginx #启动nginx容器 docker run -id --name nginx -p 80:80 容器id #创建挂载目录 cd /tmp mkdir nginx #从nginx容器中拷贝nginx配置文件 docker cp nginx:/etc/nginx/nginx.conf /opt/nginx docker cp nginx:/etc/nginx/conf.d/default.conf /opt/nginx #删除该容器 docker rm -f 容器id #重新创建nginx容器 docker run -id --name nginx -p 80:80 -v /opt/nginx/nginx.conf:/etc/nginx/nginx.conf -v /opt/nginx/default.conf:/etc/nginx/conf.d/default.conf 容器id #修改nginx.conf http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; #include /etc/nginx/conf.d/*.conf; server { listen 80; server_name 域名或公网ip; access_log off; location / { proxy_pass http://域名或公网ip:8080; proxy_set_header Host $http_host; } } } #重启容器 docker restart 容器id
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于