docker 部署 单机minio

docker 部署 单机minio

  1. 第一步

    docker pull minio/minio

  2. 第二步

    docker run -di -p 9000:9000 --name minio 
    --restart=always 
    -e "MINIO_ACCESS_KEY=admin"  
    -e "MINIO_SECRET_KEY=admin" 
    -v /docker/minio/data:/data 
    -v /docker/minio/config:/root/.minio 
    -v /etc/localtime:/etc/localtime 
    minio/minio:RELEASE.2020-05-08T02-40-49Z server /data
    

–注释 MINIO_ACCESS_KEY:账号
MINIO_SECRET_KEY:密码
/docker/minio/data 和 /docker/minio/config 自定义路径

  1. 第三步
    开放端口:
    firewall-cmd --zone=public --add-port=9000/tcp --permanent
    firewall-cmd --reload

  2. 第四步
    访问 http://ip:9000
    docker 部署 单机minio_第1张图片

    登录成功展示
    docker 部署 单机minio_第2张图片

  3. java部分
    maven

<dependency>
     <groupId>io.minio</groupId>
      <artifactId>minio</artifactId>
      <version>3.0.10</version>
</dependency>
public static AjaxResult upload(String endpoint, String accessKey,
                                    String secretKey, MultipartFile file) throws Exception {
        MinioClient minioClient = new MinioClient(endpoint, accessKey, secretKey);
        InputStream is = file.getInputStream();
        String originalFilename = file.getOriginalFilename();
        int indexOf = originalFilename.lastIndexOf(".");
        String bucket = null;
        if (indexOf == -1) {
            bucket = "other";
        } else {
            bucket = originalFilename.substring(indexOf + 1);
        }
        if (!minioClient.bucketExists(bucket)) {
            minioClient.makeBucket(bucket);
        }
        String fileName = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, DateUtils.getNowDate()) + "-" + originalFilename;
        String contentType = file.getContentType();
        minioClient.putObject(bucket, fileName, is, contentType);
        String url = minioClient.presignedGetObject(bucket, fileName);
        is.close();
        AjaxResult ajax = AjaxResult.success();
        ajax.put("fileName", fileName);
        ajax.put("url", url);
        return ajax;
    }

你可能感兴趣的:(docker,docker,java)