主页

索引

模块索引

搜索页面

配置实例

version: '3'
services:
  web:
    build: .
    ports:
    - "5000:5000"
    volumes:
    - .:/code
    - logvolume01:/var/log
    links:
    - redis
  redis:
    image: redis
volumes:
  logvolume01: {}

version

version: '3.6'  # 使用的Docker Compose版本号

services

services:  # 定义了一个或多个服务
  api:  # 服务名称为"api"
    image: quay.io/go-skynet/local-ai:latest  # 使用的Docker镜像

build

build:  # 构建选项,用于构建自定义镜像
  context: .  # Dockerfile所在的上下文路径,通常是当前目录
  dockerfile: Dockerfile  # 指定要使用的Dockerfile文件

volumes

如下两条的区别:

volumes:
  - ./models:/models:cached
volumes:
  - ./models:/models

:cached选项是用来优化性能的。
这个选项告诉Docker将本地文件系统中的数据缓存到内存中,以加快容器访问这些文件的速度。

实例

drone实例

version: '2'
services:
  drone-server:
    image: drone/drone:0.8.2
    ports:
      - 3800:8000
      - 9000
    volumes:
      - /etc/drone:/var/lib/drone/
    restart: always
    environment:
      # 是否允许注册,false 后只有在 DRONE_ADMIN 变量中指定的账户才能登录
      - DRONE_OPEN=true
      # Drone可公开访问的地址
      - DRONE_HOST=http://ci.eming.li
      # 配置 Git 仓库,只能同时使用一种仓库
      # Github 仓库需要配置上问申请到的 client id 和 client secret
      - DRONE_GITHUB=true
      - DRONE_GITHUB_CLIENT=003bd43da3380e8d7982
      - DRONE_GITHUB_SECRET=9f4a76bf7c70e5caf1120af5db1b3dcd8db5f209
      # Drone Server 和 Agent 的通信密钥
      - DRONE_SECRET=4a6a6J8LJ4Wc82Ukjww1634ev
  drone-agent:
    image: drone/agent:0.8.2
    command: agent
    restart: always
    depends_on:
      - drone-server
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      # 配置 SERVER 地址
      - DRONE_SERVER=drone-server:9000
      # 配置与 SERVER 通信的密钥,需要与 Server 配置的保持一致
      - DRONE_SECRET=4a6a6J8LJ4Wc82Ukjww1634ev

etcd集群

version: "3.6"
services:

  node1:
    image: quay.io/coreos/etcd
    volumes:
      - node1-data:/etcd-data
    expose:
      - 2379
      - 2380      
    networks:
      cluster_net:
        ipv4_address: 172.16.238.100
    environment:
      - ETCDCTL_API=3
    command:
      - /usr/local/bin/etcd
      - --data-dir=/etcd-data
      - --name
      - node1
      - --initial-advertise-peer-urls
      - http://172.16.238.100:2380
      - --listen-peer-urls
      - http://0.0.0.0:2380
      - --advertise-client-urls
      - http://172.16.238.100:2379
      - --listen-client-urls
      - http://0.0.0.0:2379
      - --initial-cluster
      - node1=http://172.16.238.100:2380,node2=http://172.16.238.101:2380,node3=http://172.16.238.102:2380
      - --initial-cluster-state
      - new
      - --initial-cluster-token
      - docker-etcd

  node2:
    image: quay.io/coreos/etcd
    volumes:
      - node2-data:/etcd-data
    networks:
      cluster_net:
        ipv4_address: 172.16.238.101
    environment:
      - ETCDCTL_API=3
    expose:
      - 2379
      - 2380
    command:
      - /usr/local/bin/etcd
      - --data-dir=/etcd-data
      - --name
      - node2
      - --initial-advertise-peer-urls
      - http://172.16.238.101:2380
      - --listen-peer-urls
      - http://0.0.0.0:2380
      - --advertise-client-urls
      - http://172.16.238.101:2379
      - --listen-client-urls
      - http://0.0.0.0:2379
      - --initial-cluster
      - node1=http://172.16.238.100:2380,node2=http://172.16.238.101:2380,node3=http://172.16.238.102:2380
      - --initial-cluster-state
      - new
      - --initial-cluster-token
      - docker-etcd

  node3:
    image: quay.io/coreos/etcd
    volumes:
      - node3-data:/etcd-data
    networks:
      cluster_net:
        ipv4_address: 172.16.238.102
    environment:
      - ETCDCTL_API=3
    expose:
      - 2379
      - 2380
    command:
      - /usr/local/bin/etcd
      - --data-dir=/etcd-data
      - --name
      - node3
      - --initial-advertise-peer-urls
      - http://172.16.238.102:2380
      - --listen-peer-urls
      - http://0.0.0.0:2380
      - --advertise-client-urls
      - http://172.16.238.102:2379
      - --listen-client-urls
      - http://0.0.0.0:2379
      - --initial-cluster
      - node1=http://172.16.238.100:2380,node2=http://172.16.238.101:2380,node3=http://172.16.238.102:2380
      - --initial-cluster-state
      - new
      - --initial-cluster-token
      - docker-etcd

volumes:
  node1-data:
  node2-data:
  node3-data:

networks:
  cluster_net:
    driver: bridge
    ipam:
      driver: default
      config:
      -
        subnet: 172.16.238.0/24

LocalAI

version: '3.6'

services:  # 定义了一个或多个服务
  api:  # 服务名称为"api"
    image: quay.io/go-skynet/local-ai:latest  # 使用的Docker镜像
    build:  # 构建选项,用于构建自定义镜像
      context: .  # Dockerfile所在的上下文路径,通常是当前目录
      dockerfile: Dockerfile  # 指定要使用的Dockerfile文件
    ports:  # 指定端口映射规则,将主机端口映射到容器端口
      - 8080:8080  # 将主机的8080端口映射到容器的8080端口
    env_file:  # 指定环境变量文件,用于将环境变量传递给容器
      - .env  # 使用当前目录下的.env文件
    volumes:  # 定义卷挂载规则,将主机目录挂载到容器中
      - ./models:/models:cached  # 将主机当前目录下的models目录挂载到容器中的/models目录,并使用缓存选项
    command: ["/usr/bin/local-ai"]  # 指定容器启动时要运行的命令

主页

索引

模块索引

搜索页面