I have a basic docker-compose.yml file that creates a MiniO container for me to interact with, for development purposes:
version: "3.5"
services:
storage:
image: minio/minio:latest
command: server --console-address ":9001" /data
ports:
- 9000:9000
- 9001:9001
volumes:
- storage-data:/data
environment:
- MINIO_ROOT_USER=admin
- MINIO_ROOT_PASSWORD=superstrongpassword
healthcheck:
test: timeout 5s bash -c ':> /dev/tcp/127.0.0.1/9000' || exit 1
interval: 5s
retries: 1
start_period: 5s
timeout: 5s
volumes:
storage-data:
I am then configuring MiniO using their .NET Nuget Package:
services.AddMinio("admin", "superstrongpassword");
I am then using the MiniO Client to create a bucket:
public class MinioStorageService(IMinioClient minioClient) : IStorageService
{
public async Task<string> CreateContainerAsync()
{
var containerName = Guid.NewGuid().ToString().ToLower();
var makeBucketArguments = new MakeBucketArgs().WithBucket(containerName);
await minioClient.MakeBucketAsync(makeBucketArguments);
return containerName;
}
}
Registering this in the service container:
builder.Services.AddScoped<IStorageService, MinioStorageService>();
and then finally, inside a controller I am doing the following:
[ApiController]
[Route("/hello")]
public class HelloWorldController(IStorageService storageService) : ControllerBase
{
[HttpGet]
public async Task<IActionResult> CreateContainerAsync()
{
var bucketId = await storageService.CreateContainerAsync();
return Ok(bucketId);
}
}
I am getting the new GUID (bucket name) returned to the browser when this is completed and no exceptions are being thrown, however, upon inspecting the browser (localhost:9001) I can see that no buckets have been created.
Please note that the .NET Application is running on the host machine, and is not within a Docker container itself.
I have tried the following:
- Alternating between Docker images
minio/minio&quay.io/minio/minio - Changing ports from 9000 to 9001
- Tried to access via access keys, added admin in case it was a policy.
- Creating the client manually without dependency injection
- Turning off
.WithSSL(false) - Manually setting the endpoint.
Unfortunately, none of these seem to work. The only thing I can see in the logs is a warning of:
- The standard parity is set to 0. This can lead to data loss.
However, I don't believe that to be a problem.
The health check also seems to be performing ok.
EDIT:
I navigated to the docker terminal for this container ran the following commands:
mc alias set testing http://127.0.0.1:9000 admin superstrongpassword
mc mb testing/test-bucket1
Doing this, I can confirm that the bucket was successfully created with the credentials provided.
Further investigation:
I have now plugged my code to use the play.min.io demo. I can confirm that this works and creates the bucket as expected, so it is likely an access / Docker issue.