Docker-compose安装MinIO

0 评论 359 浏览
  1. 新建文件docker-compose.yml
vi docker-compose.yml
  1. 输入以下内容
version: '3.1'
services: 
    minio:
      image: minio/minio
      container_name: minio
      restart: always
      ports:
        - 9000:9000
      command: server /data  #指定容器中的目录 /data
      environment:
        MINIO_ACCESS_KEY: minio    #管理后台用户名
        MINIO_SECRET_KEY: minioxxx #管理后台密码,最小8个字符
      volumes:
        - ./data:/data              #映射当前目录下的data目录至容器内/data目录
        - ./config:/root/.minio/     #映射配置目录
  1. 运行命令
docker-compose up -d
  1. 单机集群部署
#docker-compose.yaml
version: "3.7"

# starts 4 docker containers running minio server instances. Each
# minio server's web interface will be accessible on the host at port
# 9001 through 9004.
services:
    minio1:
        image: minio/minio
        volumes:
            - data1-1:/data1
            - data1-2:/data2
        ports:
            - "9001:9000"
        environment:
            MINIO_ACCESS_KEY: minio
            MINIO_SECRET_KEY: minio123
        command: server http://minio{1...4}/data{1...2}
        healthcheck:
            test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
            interval: 30s
            timeout: 20s
            retries: 3

    minio2:
        image: minio/minio
        volumes:
            - data2-1:/data1
            - data2-2:/data2
        ports:
            - "9002:9000"
        environment:
            MINIO_ACCESS_KEY: minio
            MINIO_SECRET_KEY: minio123
        command: server http://minio{1...4}/data{1...2}
        healthcheck:
            test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
            interval: 30s
            timeout: 20s
            retries: 3

    minio3:
        image: minio/minio
        volumes:
            - data3-1:/data1
            - data3-2:/data2
        ports:
            - "9003:9000"
        environment:
            MINIO_ACCESS_KEY: minio
            MINIO_SECRET_KEY: minio123
        command: server http://minio{1...4}/data{1...2}
        healthcheck:
            test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
            interval: 30s
            timeout: 20s
            retries: 3

    minio4:
        image: minio/minio
        volumes:
            - data4-1:/data1
            - data4-2:/data2
        ports:
            - "9004:9000"
        environment:
            MINIO_ACCESS_KEY: minio
            MINIO_SECRET_KEY: minio123
        command: server http://minio{1...4}/data{1...2}
        healthcheck:
            test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
            interval: 30s
            timeout: 20s
            retries: 3

## By default this config uses default local driver,
## For custom volumes replace with volume driver configuration.
volumes:
    data1-1:
    data1-2:
    data2-1:
    data2-2:
    data3-1:
    data3-2:
    data4-1:
    data4-2: