Search code examples
dockeramazon-s3minio

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


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?


Solution

  • 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.