Docker compose with MinIO `entrypoint` raises `config is not a recognized command`

typescript
Ethan JacksonI was using the following service definition in a docker compose
file without problems,
to create a MinIO bucket.
createbucket:
image: minio/mc:latest
networks:
- main-network
entrypoint: >
/bin/sh -c "
/usr/bin/mc config host add --api s3v4 s3 http://minio:9000 <name> <password>;
/usr/bin/mc mb s3/media/;
/usr/bin/mc anonymous set download s3/media;
"
depends_on:
- minio
But after running docker system prune
my build raised these errors:
project-createbucket-1 | mc: <ERROR> `config` is not a recognized command. Get help using `--help` flag.
project-createbucket-1 | mc: <ERROR> Unable to make bucket `s3/media/`. The AWS Access Key Id you provided does not exist in our records.
project-createbucket-1 | mc: <ERROR> Unable to set anonymous `download` for `s3/media`. The AWS Access Key Id you provided does not exist in our records.
project-createbucket-1 exited with code 1
The entrypoint
script above seems to be commonly used boiler plate found in a number
of MinIO tutorials and resources. I have found indications that the
mc config host add
syntax is deprecated. What should I replace it with?
Answer
This alternative seems to work:
createbucket:
image: minio/mc:latest
networks:
- main-network
entrypoint: >
/bin/sh -c "
mc alias set s3 http://minio:9000 <name> <password>;
mc mb --ignore-existing s3/media;
mc anonymous set download s3/media;
"
depends_on:
- minio
I.e. I used mc alias set
instead of mc config host add
.