Docker/Docker-Compose 应用集

    522

docker/docker-composeYaml文件的应用,之前分开太过杂乱,现整合,并保持更新

MySQL

docker

docker run -p 3306:3306 --name mysql8 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:latest

docker-compose.yaml

version: "3"
​
services:
  mysql:
    image: mysql:5.7
    container_name: mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: root
      TZ: Asia/Shanghai
    ports:
      - "3306:3306"
    command:
      --lower_case_table_names=1
      --character-set-server=utf8mb4
      --collation-server=utf8mb4_general_ci
    volumes:
      - /mydb/mysql/data:/var/lib/mysql           #数据文件挂载
      - /mydb/mysql/log:/var/log/mysql            #日志文件挂载

MongoDB

docker

docker run -p 27017:27017 --name mongo-container -e MONGO_INITDB_ROOT_USERNAME=root -e MONGO_INITDB_ROOT_PASSWORD=root -d mongo:latest

docker-compose.yaml

version: "3"
services:
  mongodb:
    image: mongo:latest
    container_name: mongodb
    restart: always
    environment:
      - MONGO_INITDB_ROOT_USERNAME=root
      - MONGO_INITDB_ROOT_PASSWORD=root
    ports:
      - "27017:27017"
    command:
      - "--auth"
    volumes:
      - ./mongo/data:/data/db

Mariadb

docker-compose.yaml

version: '3.1'
services:
  mariadb:
    image: mariadb:10.6
    container_name: mariadb
    network_mode: host
    restart: always
    environment:
      # 自定义用户与密码
      MARIADB_USER: ""
      MARIADB_PASSWORD: ""
      # root 用户的密码
      MARIADB_ROOT_PASSWORD: "root"
      TZ: "Asia/Shanghai"
    ports:
      - "3306:3306"
    volumes:
      - ./data:/var/lib/mysql
      - ./log:/var/log/mysql

Halo

docker-compose.yaml

version: "3"

services:
  halo:
    image: registry.fit2cloud.com/halo/halo:2.19
    container_name: halo
    restart: on-failure:3
    network_mode: host
    volumes:
      - ./halo2:/root/.halo2
    command:
      # 修改为自己已有的数据库配置
      - --spring.r2dbc.url=r2dbc:pool:mariadb://localhost:3306/halodb
      - --spring.r2dbc.username=root
      - --spring.r2dbc.password=root
      - --spring.sql.init.platform=mariadb
      # 外部访问地址,请根据实际需要修改
      - --halo.external-url=http://localhost:8090/
      # 端口号 默认8090
      - --server.port=8090

DPanel

Docker 可视化面板系统,提供完善的 docker 管理功能。

https://donknap.github.io/dpanel-docs/#/zh-cn/install/docker

docker Lite版

docker run -it -d --name dpanel --restart=always \
 -p 8807:8080 -e APP_NAME=dpanel \
 -v /var/run/docker.sock:/var/run/docker.sock -v /opt/dpanel:/dpanel \
 -e INSTALL_USERNAME=admin -e INSTALL_PASSWORD=admin \
 dpanel/dpanel:lite

Certd

SSL生成工具

https://github.com/certd/certd

docker-compose.yaml

version: '3.3'

services:
    nascab:
        image: ypptec/nascab
        container_name: nascab
        network_mode: host
        restart: always
        ports:
            - '8580:80'
            - '8543:443'
            - '8521:21'
        volumes:
            - './nascab/nascabData:/root/.local/share/nascab' #文件缓存目录
            - './nascab/data:/myData'  #映射data目录   

Immich

Immich 是一个非常好用的开源的照片管理工具,支持 iOS 和 Android App.

https://immich.app/

由于 immich 依赖的服务比较多,使用官方推荐使用 Compose 的方式来安装。

首先从 immich 官网 下载配置文件:docker-compose.ymlexample.env

也可以按照下面文件编写【与官方相同,删除英文注释,修改上传照片路径,数据库路径即可】

  1. example.envdocker-compose.yaml 放至相同路径文件夹下;

  2. example.env 重命名为 .env

  3. docker compose up -d 等待完成即可。

example.env

# 上传照片路径
UPLOAD_LOCATION=/home/immich/Photo
# 数据库路径
DB_DATA_LOCATION=/home/immich/db
# 时区 中国上海
TZ=Asia/Shanghai
# 版本
IMMICH_VERSION=release
# 数据库:用户密码数据库名
DB_PASSWORD=postgres
DB_USERNAME=postgres
DB_DATABASE_NAME=immich

docker-compose.yaml

name: immich

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    ports:
      - 2283:3001
    depends_on:
      - redis
      - database
    restart: always
    healthcheck:
      disable: false

  immich-machine-learning:
    container_name: immich_machine_learning
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
    volumes:
      - model-cache:/cache
    env_file:
      - .env
    restart: always
    healthcheck:
      disable: false

  redis:
    container_name: immich_redis
    image: docker.io/redis:6.2-alpine@sha256:2d1463258f2764328496376f5d965f20c6a67f66ea2b06dc42af351f75248792
    healthcheck:
      test: redis-cli ping || exit 1
    restart: always

  database:
    container_name: immich_postgres
    image: docker.io/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:90724186f0a3517cf6914295b5ab410db9ce23190a2d9d0b9dd6463e3fa298f0
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
      POSTGRES_INITDB_ARGS: '--data-checksums'
    volumes:
      - ${DB_DATA_LOCATION}:/var/lib/postgresql/data
    healthcheck:
      test: pg_isready --dbname='${DB_DATABASE_NAME}' --username='${DB_USERNAME}' || exit 1; Chksum="$$(psql --dbname='${DB_DATABASE_NAME}' --username='${DB_USERNAME}' --tuples-only --no-align --command='SELECT COALESCE(SUM(checksum_failures), 0) FROM pg_stat_database')"; echo "checksum failure count is $$Chksum"; [ "$$Chksum" = '0' ] || exit 1
      interval: 5m
      start_interval: 30s
      start_period: 5m
    command: ["postgres", "-c", "shared_preload_libraries=vectors.so", "-c", 'search_path="$$user", public, vectors', "-c", "logging_collector=on", "-c", "max_wal_size=2GB", "-c", "shared_buffers=512MB", "-c", "wal_compression=on"]
    restart: always

volumes:
  model-cache:

自用下载:immich.zip

Emby

开心版,其实感觉也不太好用 即使使用了魔法

docker-compose.yaml

version: "3.9"
services:
    emby:
      image: tearsful/embyserver:latest
      container_name: emby
      network_mode: host
      ports:
        - 8096:8096
        - 8920:8920
        - 1900:1900/udp
        - 7359:7359/udp
      environment:
        - PUID=1000
        - PGID=1000
        - GIDLIST=0
        - TZ=Asia/Shanghai
        - ALL_PROXY=socks5://192.168.110.168:7891
        - HTTP_PROXY=http://192.168.110.168:7890
        - HTTPS_PROXY=http://192.168.110.168:7890
      devices:
        - /dev/dri:/dev/dri
      volumes:
        - /home/emby/media:/media
      restart: unless-stopped

Clash & Yacd

docker-compose.yaml

version: "3"

services:
  clash:
    image: dreamacro/clash-premium
    container_name: clash
    network_mode: host
    hostname: clash
    restart: unless-stopped
    ports:
      - 7890:7890
      - 7891:7891
      - 9090:9090
    volumes:
      - ./config.yaml:/root/.config/clash/config.yaml
    environment:
      - TZ=Asia/Shanghai

  yacd:
    image: ghcr.io/haishanh/yacd:master
    container_name: yacd
    network_mode: host
    hostname: yacd
    restart: unless-stopped
    ports:
      - 8007:80
    environment:
      - TZ=Asia/Shanghai
    depends_on:
      - clash

目前最好用自建音乐部署了吧

docker-compose.yaml

services:
  navidrome:
    image: deluan/navidrome:latest
    container_name: navidrome
    ports:
      - 4533:4533 #左侧端口如有冲突,可随意修改
    volumes:
      - "/vol1/1000/Docker/navidrome/data:/data"
      - "/vol1/1000/Media/music:/music:ro"
    environment:
      #程序默认语言
      - ND_DEFAULTLANGUAGE=zh-Hans
      #启用GRAVATAR头像
      - ND_ENABLEGRAVATAR=true
      #关闭转码,如需要转码请设置为true
      - ND_ENABLETRANSCODINGCONFIG=false
      #SPOTIFY相关
      # - ND_SPOTIFY_ID=
      # - ND_SPOTIFY_SECRET=
      #LAST.FM相关
      # - ND_LASTFM_LANGUAGE=zh
      # - ND_LASTFM_APIKEY=
      # - ND_LASTFM_SECRET=
      #PROXY相关
      - HTTP_PROXY=http://192.168.0.168:7890
      - HTTPS_PROXY=http://192.168.0.168:7890
    restart: unless-stopped

消息盒子

# 暂无消息 #

只显示最新10条未读和已读信息