Docker-compose的一些常用文档

Docker-compose的一些常用文档

在使用volumes做卷映射时,有两种映射方式:

  • 相对路径:相对于 docker-compose.yml 文件所在目录的路径。
volumes:
  - ./relative/path/to/data:/var/lib/postgresql/data
  • 绝对路径:主机上的绝对路径。
volumes:
  - /absolute/path/to/data:/var/lib/postgresql/data

Jellyfin

version: "3"
services:
  jellyfin:
    image: jellyfin/jellyfin
    container_name: jellyfin
    stdin_open: true
    tty: true
    restart: always
    ports:
      - 8096:8096
    volumes:
      - /mnt/config:/config
      - /mnt/nas:/nas
    privileged: true

Portainer

version: '3'
services:
  portainer:
    image: "portainer/portainer-ce:latest"
    restart: always
    ports:
      - "9000:9000"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /home/docker/Portainer/data:/data
      - /home/docker/Portainer/public:/public

Docker管理面板Portainer中文汉化 新增CE、EE企业版汉化 - 我不是矿神 (imnks.com)下载汉化文件后将public文件夹替换


Webdav

version: '3'
services:
  webdav:
    image: "bytemark/webdav:latest"
    restart: always
    ports:
      - "8060:80"
    enviroment:
      AUTH_TYPE=Basic
      USERNAME=XIAOBAI
      PASSWORD=XIAOBAI
    volumes:
      - /home/docker/webdav/dav:/var/lib/dav

halo

version: "3"

services:
  halo:
    image: halohub/halo:2.13
    restart: on-failure:3
    volumes:
      - home/docker/halo2:/root/.halo2
    ports:
      - "8090:8090"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8090/actuator/health/readiness"]
      interval: 30s
      timeout: 5s
      retries: 5
      start_period: 30s
    command:
      # 外部访问地址,请根据实际需要修改
      - --halo.external-url=http://localhost:8090/

Zfile(云盘)

version: '3'
services:
    zfile:
        container_name: zfile
        restart: always
        ports:
            - '8100:8080'
        volumes:
            - '/mnt/zfile/db:/root/.zfile-v4/db'
            - '/mnt/zfile/logs:/root/.zfile-v4/logs'
            - '/mnt/zfile/file:/data/file'
        image: zhaojun1998/zfile

MySQL

官方文档:https://dev.mysql.com/doc/refman/9.0/en/docker-mysql-getting-started.html#docker-starting-mysql-server

注册token
  • 点击网址:https://container-registry.oracle.com/

  • 登录网站:点击右上角的Sign in按钮并登录

  • 生成密钥:点击账号下拉框中的Auth Token按钮,然后点击Generate Secret Key按钮并保存

注册仓库
docker login container-registry.oracle.com
mkdir -p /home/mysql/{conf,data,logs}
version: '3.0'
services:
  mysql:
    image: container-registry.oracle.com/mysql/community-server:9.0
    container_name: mysql
    ports:
      - "3306:3306"
    volumes:
      - /home/mysql/conf/my.cnf:/etc/my.cnf
      - /home/mysql/logs:/var/logs
      - /home/mysql/data:/var/lib/mysql
    restart: unless-stopped
    privileged: tru

/home/docker/mysql/conf/my.cnf

[mysqld]
user=mysql

开通远程主机连接权限

首先,使用docker logs mysql获取到初始密码

登录后,使用ALTER USER 'root'@'localhost' IDENTIFIED BY 'Zhuwenxue2002'修改密码

# 在本机登入mysql后,更改 “mysql” 数据库里的 “user” 表里的 “host” 项,从”localhost”改称’%’。

mysql>use mysql;

# 查询出数据库的用户名

mysql>select host,user,password from user;

# 把用户表里面的host项改为“%”

mysql>update user set host = ‘%’ where user =’root’;

mysql>flush privileges;    #刷新用户权限表

MinIO

version: '3'
services:
  minio:
    image: minio/minio
    hostname: "minio"
    ports:
      - 9000:9000 # api 端口
      - 9001:9001 # 控制台端口
    environment:
      MINIO_ACCESS_KEY: xiaobai    #管理后台用户名
      MINIO_SECRET_KEY: Zhuwenxue2002 #管理后台密码,最小8个字符
    volumes:
      - ./data:/data               #映射当前目录下的data目录至容器内/data目录
      - ./config:/root/.minio/     #映射配置目录
    command: server --console-address ':9001' /data  #指定容器中的目录 /data
    privileged: true
    restart: always

PgSQL

version: '3.1'

services:
  db:
    image: postgres:latest
    restart: always
    environment:
      POSTGRES_PASSWORD: Zhuwenxue2002
    ports:
      - "5432:5432"
    volumes:
      - ./data:/var/lib/postgresql/data
      - ./log:/var/log/postgresql