Skip to content

Instantly share code, notes, and snippets.

@aliartiza75
Last active August 11, 2023 16:53
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save aliartiza75/d3bab97ff1fdafa2d9ab9436a52012f0 to your computer and use it in GitHub Desktop.
Save aliartiza75/d3bab97ff1fdafa2d9ab9436a52012f0 to your computer and use it in GitHub Desktop.
Command to use mini/mc with minio server
# Step 1 : Start minio server with non-persistent data storage policy
#
# Description: -p 9000:9000: Minio server runs on port 9000 inside the docker container, -e 9000:9000 command is exposing the internal port on
# on external port.
#
# -e "MINIO_ACCESS_KEY=access_key": It sets an envrionment variable inside container named as MINIO_ACCESS_KEY
# with the value provided by user. It will be used when a user wants to access
# minio server
#
# -e "MINIO_SECRET_KEY=access_key_secret": It sets an envrionment variable inside container named as MINIO_SECRET_KEY
# with the value provided by user. It will be used when a user wants to access
# minio server
# minio/minio: It is the name of the image
#
# Once the server has started successfully then MINIO UI can be accessed on this URL: http://127.0.0.1:9000/
$ sudo docker run -p 9000:9000 -e "MINIO_ACCESS_KEY=access_key" -e "MINIO_SECRET_KEY=access_key_secret" minio/minio server /data
# Step 2 : Start the mc container
# Description: --net=host: It enfores the container to use the host networking.
#
# -it: run the container in the interactive mode.
#
# --entrypoint=/bin/sh: It runs /bin/sh command once the docker container is started
#
# minio/mc: It is the name of the image
#
$ sudo docker run --net=host -it --entrypoint=/bin/sh minio/mc
# Step 3: Connect mc (minio client) to minio server
# Description: It adds a new host named as minio that is running on the address [http://127.0.0.1:9000] using
# these keys access_key and access_key_secret
$ mc config host add minio http://127.0.0.1:9000 access_key access_key_secret
# Step 4: Create a new bucket
# Description: It creates a new bucket named as newbucket on minio host
$ mc mb minio/newbucket
# Step 5: Copy a local file on minio server
# Description: It copies a file named as 123.txt to the newly created bucket named as newbucket
$ mc cp 123.txt minio/newbucket/123.txt
# Step 6: Sync the folder on minio server locally
# Description: --newer-than 7: It filter object(s) newer than 7 days
$ mc mirror --newer-than 7 p minio/minioserverbucket
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment