侧边栏壁纸
博主头像
呱仔爱学习 博主等级

✨基础不牢,地动山摇✨

  • 累计撰写 3 篇文章
  • 累计创建 4 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

Docker部署常用服务

呱仔
2024-10-12 / 0 评论 / 4 点赞 / 57 阅读 / 0 字

前言

dockerdocker-compose的安装教程,参考以下文章:

Docker部署mysql

配置挂载

创建配置文件存放目录

mkdir -p ~/mysql/conf

编写配置文件my.cnf,放入~/mysql/conf目录:

#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password
skip-host-cache
skip-name-resolve
datadir=/var/lib/mysql
socket=/var/run/mysqld/mysqld.sock
secure-file-priv=/var/lib/mysql-files
user=mysql

pid-file=/var/run/mysqld/mysqld.pid
[client]
socket=/var/run/mysqld/mysqld.sock

!includedir /etc/mysql/conf.d/

数据挂载

创建数据文件存放目录

mkdir -p ~/mysql/data

容器部署

编写docker-compose.yaml文件,放入~/mysql目录中:

version: '3'

services:
  mysql:
    image: mysql:8.1.0
    container_name: mysql
    restart: always
    volumes:
      - ~/mysql/conf:/etc/mysql/conf.d
      - ~/mysql/data:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro
    environment:
      - MYSQL_ROOT_PASSWORD=123456
    ports:
      - 3306:3306

部署容器

docker compose up -d

Docker部署redis

配置挂载

创建配置文件存放目录

mkdir -p ~/redis/conf

编写配置文件redis.conf,放入~/redis/conf目录:

requirepass 123456
appendonly yes

数据挂载

创建数据文件存放目录

mkdir -p ~/redis/data

容器部署

编写docker-compose.yaml文件,放入~/redis目录中:

version: "3"

services:
  halo:
    image: redis:7.2.0
    container_name: redis
    restart: always
    volumes:
      - ~/redis/conf/redis.conf:/etc/redis/redis.conf
      - ~/redis/data:/data
    command: redis-server /etc/redis/redis.conf
    ports:
      - 6379:6379

部署容器

docker compose up -d

Docker部署halo

数据挂载

创建数据文件存放目录

mkdir -p ~/halo/halo2

容器部署

编写docker-compose.yaml文件,放入~/halo目录中:

version: "3"

services:
  halo:
    image: halohub/halo:2.10
    container_name: halo
    restart: on-failure:3
    volumes:
      - ~/halo/halo2:/root/.halo2
    command:
      # 修改为自己已有的 MySQL 配置
      - --spring.r2dbc.url=r2dbc:pool:mysql://127.0.0.1:3306/halo
      - --spring.r2dbc.username=root
      - --spring.r2dbc.password=123456
      - --spring.sql.init.platform=mysql
      # 外部访问地址,请根据实际需要修改
      - --halo.external-url=http://127.0.0.1:8090/
      # 端口号 默认8090
      - --server.port=8090
    ports:
      - 8090:8090

部署容器

docker compose up -d

4

评论区