1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

MinIO(S3互換環境)をDockerで構築する

Last updated at Posted at 2022-11-23

概要

  • ローカルでS3環境が欲しいのでDockerで簡易に構築する
  • あくまで学習用なので必要最低限の設定としておく
  • MinIOの操作はCLIから行うのでmcコマンドもインストールする

Docker設定

  • docker-composeは下記の通り
    • コンテナイメージはDockerHubから最新をPullする
    • "MINIO_ROOT_PASSWORD"は短いとコンテナが起動しないので注意
docker-compose.yml
version: '3.7'

services:
  minio:
    image: minio/minio:RELEASE.2022-11-17T23-20-09Z
    container_name: minio
    hostname: minio
    ports:
      - "9000:9000"
      - "9001:9001"
    volumes:
      - ./data:/data
    command: "server /data --console-address :9001"
    environment:
      MINIO_ROOT_USER: minio
      MINIO_ROOT_PASSWORD: minio1234

mcコマンド設定

  • 公式ドキュメントがあるので一読しておく >> MinIO Clinet
    • 環境(Linux,Mac...)ごとに用意されているみたいなので今回はLinuxを選択
# cd /tmp
# wget https://dl.min.io/client/mc/release/linux-amd64/mc
# ls -l
# chmod +x mc
# ls -l
# mv mc /usr/local/bin/
  • 次にコンフィグファイルを用意する
# mdkir ~/.mc
# touch ~/.mc/config.json
# vi ~/.mc/config.json
config.json
{
	"version": "10",
	"aliases": {
		"minio": {
			"url": "http://localhost:9000/",
			"accessKey": "minio",
			"secretKey": "minio1234",
			"api": "S3v4",
			"path": "auto"
		}
	}
}
  • Minioコンテナを立ち上げてCLI操作できるか確認する
# docker-compose up -d
Creating network "minio_default" with the default driver
Creating minio ... done

# mc mb minio/sample01
Bucket created successfully `minio/sample01`.
# mc ls minio/sample01
# mc ls minio
[2022-11-23 17:30:45 JST]     0B sample01/
  • バケットの作成ができれば環境構築完了
  • ブラウザでhttp://localhost:9001へアクセスしてGUIからも確認

参考

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?