2020-03-24 17:51:06 -04:00
# MinIO Docker Quickstart Guide [![Slack](https://slack.min.io/slack?type=svg)](https://slack.min.io) [![Docker Pulls](https://img.shields.io/docker/pulls/minio/minio.svg?maxAge=604800)](https://hub.docker.com/r/minio/minio/)
2015-11-06 19:46:04 -05:00
2017-03-28 16:54:19 -04:00
## Prerequisites
Docker installed on your machine. Download the relevant installer from [here ](https://www.docker.com/community-edition#/download ).
2017-01-07 21:35:12 -05:00
2019-04-09 14:39:42 -04:00
## Run Standalone MinIO on Docker.
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.
2016-07-19 17:30:32 -04:00
2016-07-21 17:58:16 -04:00
```sh
2021-07-11 22:31:40 -04:00
docker run \
-p 9000:9000 \
-p 9001:9001 \
2021-01-05 13:22:57 -05:00
-e "MINIO_ROOT_USER=AKIAIOSFODNN7EXAMPLE" \
-e "MINIO_ROOT_PASSWORD=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \
2021-09-01 21:48:26 -04:00
quay.io/minio/minio server /data --console-address ":9001"
2016-03-24 20:28:04 -04:00
```
2015-11-06 19:46:04 -05:00
2019-04-09 14:39:42 -04:00
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
2016-02-18 05:13:52 -05:00
2017-03-28 16:54:19 -04:00
#### GNU/Linux and macOS
2017-01-07 21:35:12 -05:00
```sh
2021-07-11 22:31:40 -04:00
docker run \
-p 9000:9000 \
-p 9001:9001 \
2020-07-06 09:42:34 -04:00
--name minio1 \
2017-08-17 13:56:25 -04:00
-v /mnt/data:/data \
2021-01-05 13:22:57 -05:00
-e "MINIO_ROOT_USER=AKIAIOSFODNN7EXAMPLE" \
-e "MINIO_ROOT_PASSWORD=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \
2021-09-01 21:48:26 -04:00
quay.io/minio/minio server /data --console-address ":9001"
2017-01-07 21:35:12 -05:00
```
2017-03-28 16:54:19 -04:00
#### Windows
2017-01-07 21:35:12 -05:00
```sh
2021-07-11 22:31:40 -04:00
docker run \
-p 9000:9000 \
-p 9001:9001 \
2020-07-06 09:42:34 -04:00
--name minio1 \
2017-08-17 13:56:25 -04:00
-v D:\data:/data \
2021-01-05 13:22:57 -05:00
-e "MINIO_ROOT_USER=AKIAIOSFODNN7EXAMPLE" \
-e "MINIO_ROOT_PASSWORD=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \
2021-09-01 21:48:26 -04:00
quay.io/minio/minio server /data --console-address ":9001"
2016-04-11 15:33:34 -04:00
```
2019-04-09 14:39:42 -04:00
## Run Distributed MinIO on Docker
2021-05-31 21:55:21 -04:00
Distributed MinIO can be deployed via [Docker Compose ](https://docs.min.io/docs/deploy-minio-on-docker-compose ). This means Docker Compose lets you quickly get started with Distributed MinIO on your computer - ideal for development, testing, staging environments. We recommend kubernetes based deployment for production level deployment https://github.com/minio/operator.
2017-03-28 16:54:19 -04:00
2019-04-09 14:39:42 -04:00
## MinIO Docker Tips
2017-03-28 16:54:19 -04:00
2019-04-09 14:39:42 -04:00
### MinIO Custom Access and Secret Keys
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.
2016-07-21 17:58:16 -04:00
2017-03-28 16:54:19 -04:00
#### GNU/Linux and macOS
2017-01-07 21:35:12 -05:00
```sh
2021-07-11 22:31:40 -04:00
docker run \
-p 9000:9000 \
-p 9001:9001 \
--name minio1 \
2021-01-05 13:22:57 -05:00
-e "MINIO_ROOT_USER=AKIAIOSFODNN7EXAMPLE" \
-e "MINIO_ROOT_PASSWORD=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \
2017-08-17 13:56:25 -04:00
-v /mnt/data:/data \
2021-09-01 21:48:26 -04:00
quay.io/minio/minio server /data --console-address ":9001"
2017-01-07 21:35:12 -05:00
```
2017-03-28 16:54:19 -04:00
#### Windows
2017-04-08 04:43:40 -04:00
```powershell
2021-07-11 22:31:40 -04:00
docker run \
-p 9000:9000 \
-p 9001:9001 \
--name minio1 \
2021-01-05 13:22:57 -05:00
-e "MINIO_ROOT_USER=AKIAIOSFODNN7EXAMPLE" \
-e "MINIO_ROOT_PASSWORD=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \
2017-08-17 13:56:25 -04:00
-v D:\data:/data \
2021-09-01 21:48:26 -04:00
quay.io/minio/minio server /data --console-address ":9001"
2015-11-28 14:18:47 -05:00
```
2017-03-28 16:54:19 -04:00
2019-07-24 20:35:52 -04:00
### Run MinIO Docker as a regular user
Docker provides standardized mechanisms to run docker containers as non-root users.
2019-06-10 10:57:42 -04:00
#### GNU/Linux and macOS
2019-07-24 20:35:52 -04:00
On Linux and macOS you can use `--user` to run the container as regular user.
> NOTE: make sure --user has write permission to *${HOME}/data* prior to using `--user`.
2019-06-10 10:57:42 -04:00
```sh
2019-07-24 20:35:52 -04:00
mkdir -p ${HOME}/data
2021-07-11 22:31:40 -04:00
docker run \
-p 9000:9000 \
-p 9001:9001 \
2019-07-24 20:35:52 -04:00
--user $(id -u):$(id -g) \
--name minio1 \
2021-01-05 13:22:57 -05:00
-e "MINIO_ROOT_USER=AKIAIOSFODNN7EXAMPLE" \
-e "MINIO_ROOT_PASSWORD=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY" \
2019-07-24 20:35:52 -04:00
-v ${HOME}/data:/data \
2021-09-01 21:48:26 -04:00
quay.io/minio/minio server /data
2019-06-10 10:57:42 -04:00
```
#### Windows
2019-07-24 20:35:52 -04:00
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/ )
> NOTE: make sure your AD/Windows user has write permissions to *D:\data* prior to using `credentialspec=`.
2019-06-10 10:57:42 -04:00
```powershell
2021-07-11 22:31:40 -04:00
docker run \
-p 9000:9000 \
-p 9001:9001 \
2019-07-24 20:35:52 -04:00
--name minio1 \
--security-opt "credentialspec=file://myuser.json"
2021-01-05 13:22:57 -05:00
-e "MINIO_ROOT_USER=AKIAIOSFODNN7EXAMPLE" \
-e "MINIO_ROOT_PASSWORD=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY" \
2019-06-10 10:57:42 -04:00
-v D:\data:/data \
2021-09-01 21:48:26 -04:00
quay.io/minio/minio server /data
2019-06-10 10:57:42 -04:00
```
2019-04-09 14:39:42 -04:00
### MinIO Custom Access and Secret Keys using Docker secrets
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.
2017-04-08 04:43:40 -04:00
```
echo "AKIAIOSFODNN7EXAMPLE" | docker secret create access_key -
echo "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" | docker secret create secret_key -
```
2019-04-09 14:39:42 -04:00
Create a MinIO service using `docker service` to read from Docker secrets.
2017-04-08 04:43:40 -04:00
```
2021-09-01 21:48:26 -04:00
docker service create --name="minio-service" --secret="access_key" --secret="secret_key" quay.io/minio/minio server /data
2017-04-08 04:43:40 -04:00
```
Read more about `docker service` [here ](https://docs.docker.com/engine/swarm/how-swarm-mode-works/services/ )
2019-04-09 14:39:42 -04:00
#### MinIO Custom Access and Secret Key files
2018-10-17 13:55:55 -04:00
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
2018-01-09 00:16:25 -05:00
```
docker service create --name="minio-service" \
--secret="my_access_key" \
--secret="my_secret_key" \
2021-01-05 13:22:57 -05:00
--env="MINIO_ROOT_USER_FILE=my_access_key" \
--env="MINIO_ROOT_PASSWORD_FILE=my_secret_key" \
2021-09-01 21:48:26 -04:00
quay.io/minio/minio server /data
2018-01-09 00:16:25 -05:00
```
2021-01-05 13:22:57 -05:00
`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
2020-08-28 17:04:29 -04:00
```
2021-01-05 13:22:57 -05:00
MINIO_ROOT_USER_FILE=/vault/secrets/my_access_key
MINIO_ROOT_PASSWORD_FILE=/vault/secrets/my_secret_key
2020-08-28 17:04:29 -04:00
```
2018-01-09 00:16:25 -05:00
2017-04-08 04:43:40 -04:00
### Retrieving Container ID
2017-03-28 16:54:19 -04:00
To use Docker commands on a specific container, you need to know the `Container ID` for that container. To get the `Container ID` , run
```sh
docker ps -a
```
2016-08-30 06:53:29 -04:00
2017-03-28 16:54:19 -04:00
`-a` flag makes sure you get all the containers (Created, Running, Exited). Then identify the `Container ID` from the output.
2016-08-30 06:53:29 -04:00
2017-03-28 16:54:19 -04:00
### Starting and Stopping Containers
To start a stopped container, you can use the [`docker start` ](https://docs.docker.com/engine/reference/commandline/start/ ) command.
2017-01-07 21:35:12 -05:00
2017-03-28 16:54:19 -04:00
```sh
docker start < container_id >
```
To stop a running container, you can use the [`docker stop` ](https://docs.docker.com/engine/reference/commandline/stop/ ) command.
2016-10-14 00:34:03 -04:00
```sh
2017-03-28 16:54:19 -04:00
docker stop < container_id >
2016-08-30 06:53:29 -04:00
```
2016-09-01 19:35:26 -04:00
2019-04-09 14:39:42 -04:00
### MinIO container logs
To access MinIO logs, you can use the [`docker logs` ](https://docs.docker.com/engine/reference/commandline/logs/ ) command.
2017-01-07 21:35:12 -05:00
```sh
2017-03-28 16:54:19 -04:00
docker logs < container_id >
2017-01-07 21:35:12 -05:00
```
2019-04-09 14:39:42 -04:00
### Monitor MinIO Docker Container
To monitor the resources used by MinIO container, you can use the [`docker stats` ](https://docs.docker.com/engine/reference/commandline/stats/ ) command.
2017-03-28 16:54:19 -04:00
```sh
docker stats < container_id >
```
## Explore Further
2017-01-07 21:35:12 -05:00
2019-04-09 14:39:42 -04:00
* [Deploy MinIO on Docker Compose ](https://docs.min.io/docs/deploy-minio-on-docker-compose )
* [Distributed MinIO Quickstart Guide ](https://docs.min.io/docs/distributed-minio-quickstart-guide )
* [MinIO Erasure Code QuickStart Guide ](https://docs.min.io/docs/minio-erasure-code-quickstart-guide )