Skip to content

Instantly share code, notes, and snippets.

@egoson
Created August 24, 2024 12:15
Show Gist options
  • Select an option

  • Save egoson/9ddd4cbab29259136a74c91f957a32d5 to your computer and use it in GitHub Desktop.

Select an option

Save egoson/9ddd4cbab29259136a74c91f957a32d5 to your computer and use it in GitHub Desktop.
docker compose minio create bucket with user with credentials
# save the file nearby https://github.com/vishnubob/wait-for-it/blob/master/wait-for-it.sh !!
# ./folder
# wait-for-it.sh
# docker-compose.yml
version: '3.8'
services:
minio:
image: minio/minio:latest
container_name: minio
environment:
- MINIO_ROOT_USER=admin
- MINIO_ROOT_PASSWORD=admin123
ports:
- "9000:9000"
- "9001:9001"
volumes:
- minio_data:/data
command: server /data --console-address ':9001'
minio_mc:
image: minio/mc:latest
container_name: minio_mc
depends_on:
- minio
volumes:
- ./wait-for-it.sh:/wait-for-it.sh
entrypoint: >
sh -c "
chmod +x /wait-for-it.sh &&
/wait-for-it.sh minio:9000 --timeout=30 --strict &&
mc alias set myminio http://minio:9000 admin admin123 &&
if mc admin user info myminio your_access_key >/dev/null 2>&1; then
echo 'User your_access_key already exists, skipping user creation';
else
mc admin user add myminio your_access_key your_secret_key;
fi &&
if mc ls myminio/mybucket >/dev/null 2>&1; then
echo 'Bucket mybucket already exists, skipping bucket creation';
else
mc mb myminio/mybucket;
fi &&
if mc admin policy info myminio readwrite --user=your_access_key >/dev/null 2>&1; then
echo 'Policy readwrite already attached to user your_access_key, skipping policy attachment';
else
mc admin policy attach myminio readwrite --user=your_access_key;
fi &&
echo 'Username Minio UI: admin' &&
echo 'Password Minio UI: admin123' &&
echo 'Access Key: your_access_key' &&
echo 'Secret Access Key: your_secret_key'
"
volumes:
minio_data:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment