赞
踩
Minio是一个基于Apache License v2.0开源协议的对象存储服务,虽然轻量,却拥有着不错的性能。它兼容亚马逊S3云存储服务接口,非常适合于存储大容量非结构化的数据。
例如图片、视频、日志文件、备份数据和容器/虚拟机镜像等,而一个对象文件可以是任意大小,从几 kb 到最大 5T 不等。
命令 | 描述 |
---|---|
docker pull minio/minio | 下载最新版Minio镜像 (其实此命令就等同于 : docker pull minio/minio:latest ) |
docker pull minio/minio:RELEASE.2022-06-20T23-13-45Z.fips | 下载指定版本的Minio镜像 (xxx指具体版本号) |
检查当前所有Docker下载的镜像
docker images
一个用来存放配置,一个用来存储上传文件的目录
启动前需要先创建Minio外部挂载的配置文件( /home/minio/config),和存储上传文件的目录( /home/minio/data)
-
- mkdir -p /home/minio/config
- mkdir -p /home/minio/data
单行模式:
docker run -d -p 9000:9000 -p 9090:9090 --name=minio --restart=always -e "MINIO_ROOT_USER=minio" -e "MINIO_ROOT_PASSWORD=minio123" -v /home/data:/data -v /home/config:/root/.minio minio/minio:RELEASE.2022-09-07T22-25-02Z server /data --console-address ":9090" --address ":9000"
多行命令:
-
- docker run -p 9000:9000 -p 9090:9090 \
- --net=host \
- --name minio \
- -d --restart=always \
- -e "MINIO_ROOT_USER=minio" \
- -e "MINIO_ROOT_PASSWORD=minio123" \
- -v /home/minio/data:/data \
- -v /home/minio/config:/root/.minio \
- minio/minio:RELEASE.2022-09-07T22-25-02Z server \
- /data --console-address ":9090" -address ":9000"
有时候我们使用多行命令会运行创建容器报错,这个问题主要是 " \ "这个符号跟空格的问题,所以如果想避免出错,使用单行命令;
直接运行容器命令即可;
9090端口指的是minio的客户端端口
MINIO_ACCESS_KEY :账号
MINIO_SECRET_KEY :密码(账号长度必须大于等于5,密码长度必须大于等于8位)
访问:http://[切换ip]:9090/login 用户名:密码 minio:minio123
- #低版本的okhttp会报错提示
- <dependency>
- <groupId>io.minio</groupId>
- <artifactId>minio</artifactId>
- <version>8.4.3</version>
- </dependency>
-
- <dependency>
- <groupId>com.squareup.okhttp3</groupId>
- <artifactId>okhttp</artifactId>
- <version>4.8.1</version>
- </dependency>
- import io.minio.BucketExistsArgs;
- import io.minio.MakeBucketArgs;
- import io.minio.MinioClient;
- import io.minio.UploadObjectArgs;
- import io.minio.errors.MinioException;
-
- import java.io.IOException;
- import java.security.InvalidKeyException;
- import java.security.NoSuchAlgorithmException;
-
- public class FileUploader {
-
- public static void main(String[] args) throws IOException, NoSuchAlgorithmException, InvalidKeyException {
- try {
- // Create a minioClient with the MinIO server playground, its access key and secret key.
- MinioClient minioClient =
- MinioClient.builder()
- .endpoint("http://192.168.124.132:9000")
- .credentials("XO1JDovW2FTmGaBb", "uG6wMfylUnOVH5WzwxqnldOWw2dMshNX")
- .build();
-
- // Make 'asiatrip' bucket if not exist.
- boolean found = minioClient.bucketExists(BucketExistsArgs.builder().bucket("public").build());
- if (!found) {
- // Make a new bucket called 'asiatrip'.
- minioClient.makeBucket(MakeBucketArgs.builder().bucket("public").build());
- } else {
- System.out.println("Bucket 'public' already exists.");
- }
-
- // Upload '/home/user/Photos/asiaphotos.zip' as object name 'asiaphotos-2015.zip' to bucket
- // 'asiatrip'.
- minioClient.uploadObject(
- UploadObjectArgs.builder()
- .bucket("public")
- .object("credentials.json")
- .filename("C:/Users/lai.huanxiong/Downloads/credentials.json")
- .build());
- System.out.println("'C:/Users/lai.huanxiong/Downloads/credentials.json' is successfully uploaded as " + "object 'credentials.json' to bucket 'public'.");
- } catch (MinioException e) {
- System.out.println("Error occurred: " + e);
- System.out.println("HTTP trace: " + e.httpTrace());
- }
- }
- }
至此,Docker搭建Minio服务器和简单操作完成!!!
部分参考文献(图片): Docker 搭建 Minio 容器 (完整详细版)_docker minio-CSDN博客
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。