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?

dzang
  • 2,160
  • 2
  • 12
  • 21
  • 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? – Mihai Apr 03 '19 at 13:50
  • 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. thanks – dzang Apr 03 '19 at 14:00
  • 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 ;) – Mihai Apr 03 '19 at 14:34

1 Answers1

7

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.

Femi
  • 64,273
  • 8
  • 118
  • 148