Minio: How to make folders and files already in mount point available when starting minio server?
Asked Answered
R

1

14

I am running a Minio server using its docker image.

docker run -p 9000:9000 --name minio1 \
  -e "MINIO_ACCESS_KEY=user" \
  -e "MINIO_SECRET_KEY=pass" \
  -v /home/me/data:/data \
  minio/minio server /data

I have a couple of folders with files in the mount point. How do I make them available in Minio, do I need to upload them?

Can I put them in a folder and have it added as a bucket when I initialize the server?

EDIT:

When I open the minio web UI on localhost:9000 I don't see the files and folders that were already at the mount point.

What is the most efficient way to add all these folders to the minio server, such that a bucket is created for the first folder in the tree and then all the files inside each folder are added to their 'folder' bucket as objects? I could achieve this using Minio Python SDK, for example, by recursively walking down the folder tree and upload the files, but is that necessary?

Ratafia answered 3/4, 2019 at 13:38 Comment(3)
whatever you have locally in /home/me/data will be available inside the container in /data. I this not what you are asking? Otherwise could you give more details about what you want to achieve?Tuscarora
I know that the files will be available in the docker container, and I can see files that I upload to minio too, as they are created there. but I don't see in minio (web ui, api) the folders that were already at the mount point when I initialized the server. I tried to clarify with an edit. thanksRatafia
You can see the buckets if you map your folder to a different folder (other than /data -> can be say /data-new) and then in the last part change (server /data -> server /data-new). Unfortunately when I try to download a file I get an error. But maybe you can fix that ;)Tuscarora
I
8

For what its worth, it appears you have to use the minio command line client to accomplish this: the maintainers explicitly declined to add an option to do this internal to Minio (see https://github.com/minio/minio/issues/4769). The easiest option I'd see is basically do something like this:

docker run -p 9000:9000 --name minio1 -e "MINIO_ACCESS_KEY=user" \ 
-e "MINIO_SECRET_KEY=pass" -v /home/me/data:/data \
minio/minio server /data && docker exec -d minio1 \
"/bin/bash /usr/bin/mc config host add srv http://localhost:9000 \
user pass && /usr/bin/mc mb -p srv/bucket"

Which SHOULD launch the docker container and then exec the mc client to create the bucket bucket (change the name if there is a different folder inside data you'd like to expose).

If you're a Docker Compose fan you can try something like what's documented at https://gist.github.com/harshavardhana/cb6c0d4d220a9334a66d6259c7d54c95 or build your own image with a custom entrypoint.

Improve answered 12/4, 2019 at 13:47 Comment(1)
Workes, but hashes are not computed for existing files. Etag is set to 000000000000000000000000000Duodenary

© 2022 - 2024 — McMap. All rights reserved.