storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/docs/docker/README.md (about) 1 # MinIO Docker Quickstart Guide [](https://slack.min.io) [](https://hub.docker.com/r/minio/minio/) 2 3 ## Prerequisites 4 Docker installed on your machine. Download the relevant installer from [here](https://www.docker.com/community-edition#/download). 5 6 ## Run Standalone MinIO on Docker. 7 MinIO needs a persistent volume to store configuration and application data. However, for testing purposes, you can launch MinIO by simply passing a directory (`/data` in the example below). This directory gets created in the container filesystem at the time of container start. But all the data is lost after container exits. 8 9 ```sh 10 docker run -p 9000:9000 \ 11 -e "MINIO_ROOT_USER=AKIAIOSFODNN7EXAMPLE" \ 12 -e "MINIO_ROOT_PASSWORD=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \ 13 minio/minio server /data 14 ``` 15 16 To create a MinIO container with persistent storage, you need to map local persistent directories from the host OS to virtual config `~/.minio` and export `/data` directories. To do this, run the below commands 17 18 #### GNU/Linux and macOS 19 ```sh 20 docker run -p 9000:9000 \ 21 --name minio1 \ 22 -v /mnt/data:/data \ 23 -e "MINIO_ROOT_USER=AKIAIOSFODNN7EXAMPLE" \ 24 -e "MINIO_ROOT_PASSWORD=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \ 25 minio/minio server /data 26 ``` 27 28 #### Windows 29 ```sh 30 docker run -p 9000:9000 \ 31 --name minio1 \ 32 -v D:\data:/data \ 33 -e "MINIO_ROOT_USER=AKIAIOSFODNN7EXAMPLE" \ 34 -e "MINIO_ROOT_PASSWORD=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \ 35 minio/minio server /data 36 ``` 37 38 ## Run Distributed MinIO on Docker 39 Distributed MinIO can be deployed via [Docker Compose](https://docs.min.io/docs/deploy-minio-on-docker-compose) or [Swarm mode](https://docs.min.io/docs/deploy-minio-on-docker-swarm). The major difference between these two being, Docker Compose creates a single host, multi-container deployment, while Swarm mode creates a multi-host, multi-container deployment. 40 41 This means Docker Compose lets you quickly get started with Distributed MinIO on your computer - ideal for development, testing, staging environments. While deploying Distributed MinIO on Swarm offers a more robust, production level deployment. 42 43 ## MinIO Docker Tips 44 45 ### MinIO Custom Access and Secret Keys 46 To override MinIO's auto-generated keys, you may pass secret and access keys explicitly as environment variables. MinIO server also allows regular strings as access and secret keys. 47 48 #### GNU/Linux and macOS 49 ```sh 50 docker run -p 9000:9000 --name minio1 \ 51 -e "MINIO_ROOT_USER=AKIAIOSFODNN7EXAMPLE" \ 52 -e "MINIO_ROOT_PASSWORD=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \ 53 -v /mnt/data:/data \ 54 minio/minio server /data 55 ``` 56 57 #### Windows 58 ```powershell 59 docker run -p 9000:9000 --name minio1 \ 60 -e "MINIO_ROOT_USER=AKIAIOSFODNN7EXAMPLE" \ 61 -e "MINIO_ROOT_PASSWORD=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \ 62 -v D:\data:/data \ 63 minio/minio server /data 64 ``` 65 66 ### Run MinIO Docker as a regular user 67 Docker provides standardized mechanisms to run docker containers as non-root users. 68 69 #### GNU/Linux and macOS 70 On Linux and macOS you can use `--user` to run the container as regular user. 71 72 > NOTE: make sure --user has write permission to *${HOME}/data* prior to using `--user`. 73 ```sh 74 mkdir -p ${HOME}/data 75 docker run -p 9000:9000 \ 76 --user $(id -u):$(id -g) \ 77 --name minio1 \ 78 -e "MINIO_ROOT_USER=AKIAIOSFODNN7EXAMPLE" \ 79 -e "MINIO_ROOT_PASSWORD=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY" \ 80 -v ${HOME}/data:/data \ 81 minio/minio server /data 82 ``` 83 84 #### Windows 85 On windows you would need to use [Docker integrated windows authentication](https://success.docker.com/article/modernizing-traditional-dot-net-applications#integratedwindowsauthentication) and [Create a container with Active Directory Support](https://blogs.msdn.microsoft.com/containerstuff/2017/01/30/create-a-container-with-active-directory-support/) 86 87 > NOTE: make sure your AD/Windows user has write permissions to *D:\data* prior to using `credentialspec=`. 88 89 ```powershell 90 docker run -p 9000:9000 \ 91 --name minio1 \ 92 --security-opt "credentialspec=file://myuser.json" 93 -e "MINIO_ROOT_USER=AKIAIOSFODNN7EXAMPLE" \ 94 -e "MINIO_ROOT_PASSWORD=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY" \ 95 -v D:\data:/data \ 96 minio/minio server /data 97 ``` 98 99 ### MinIO Custom Access and Secret Keys using Docker secrets 100 To override MinIO's auto-generated keys, you may pass secret and access keys explicitly by creating access and secret keys as [Docker secrets](https://docs.docker.com/engine/swarm/secrets/). MinIO server also allows regular strings as access and secret keys. 101 102 ``` 103 echo "AKIAIOSFODNN7EXAMPLE" | docker secret create access_key - 104 echo "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" | docker secret create secret_key - 105 ``` 106 107 Create a MinIO service using `docker service` to read from Docker secrets. 108 ``` 109 docker service create --name="minio-service" --secret="access_key" --secret="secret_key" minio/minio server /data 110 ``` 111 112 Read more about `docker service` [here](https://docs.docker.com/engine/swarm/how-swarm-mode-works/services/) 113 114 #### MinIO Custom Access and Secret Key files 115 To use other secret names follow the instructions above and replace `access_key` and `secret_key` with your custom names (e.g. `my_secret_key`,`my_custom_key`). Run your service with 116 ``` 117 docker service create --name="minio-service" \ 118 --secret="my_access_key" \ 119 --secret="my_secret_key" \ 120 --env="MINIO_ROOT_USER_FILE=my_access_key" \ 121 --env="MINIO_ROOT_PASSWORD_FILE=my_secret_key" \ 122 minio/minio server /data 123 ``` 124 `MINIO_ROOT_USER_FILE` and `MINIO_ROOT_PASSWORD_FILE` also support custom absolute paths, in case Docker secrets are mounted to custom locations or other tools are used to mount secrets into the container. For example, HashiCorp Vault injects secrets to `/vault/secrets`. With the custom names above, set the environment variables to 125 ``` 126 MINIO_ROOT_USER_FILE=/vault/secrets/my_access_key 127 MINIO_ROOT_PASSWORD_FILE=/vault/secrets/my_secret_key 128 ``` 129 130 ### Retrieving Container ID 131 To use Docker commands on a specific container, you need to know the `Container ID` for that container. To get the `Container ID`, run 132 133 ```sh 134 docker ps -a 135 ``` 136 137 `-a` flag makes sure you get all the containers (Created, Running, Exited). Then identify the `Container ID` from the output. 138 139 ### Starting and Stopping Containers 140 To start a stopped container, you can use the [`docker start`](https://docs.docker.com/engine/reference/commandline/start/) command. 141 142 ```sh 143 docker start <container_id> 144 ``` 145 146 To stop a running container, you can use the [`docker stop`](https://docs.docker.com/engine/reference/commandline/stop/) command. 147 ```sh 148 docker stop <container_id> 149 ``` 150 151 ### MinIO container logs 152 To access MinIO logs, you can use the [`docker logs`](https://docs.docker.com/engine/reference/commandline/logs/) command. 153 154 ```sh 155 docker logs <container_id> 156 ``` 157 158 ### Monitor MinIO Docker Container 159 To monitor the resources used by MinIO container, you can use the [`docker stats`](https://docs.docker.com/engine/reference/commandline/stats/) command. 160 161 ```sh 162 docker stats <container_id> 163 ``` 164 165 ## Explore Further 166 167 * [Deploy MinIO on Docker Compose](https://docs.min.io/docs/deploy-minio-on-docker-compose) 168 * [Deploy MinIO on Docker Swarm](https://docs.min.io/docs/deploy-minio-on-docker-swarm) 169 * [Distributed MinIO Quickstart Guide](https://docs.min.io/docs/distributed-minio-quickstart-guide) 170 * [MinIO Erasure Code QuickStart Guide](https://docs.min.io/docs/minio-erasure-code-quickstart-guide)