1. Pull the image
docker pull minio/minio
2. Create and start the container
docker run -p 9000:9000 -p 9090:9090 \
--name minio \
-d --restart=always \
-e "MINIO_ACCESS_KEY=admin" \
-e "MINIO_SECRET_KEY=admin123" \
-v /mydata/minio/data:/data \
minio/minio server \
/data --console-address ":9090" -address ":9000"
Command explanation:
(1) The \ at the end of each line indicates that the command has not been entered yet, so do not execute it yet.
(2) -p The internal port of the container is bound to the specified host port. 9000 is the minio service port, used for service links and requests; 9090 is the minio client port, used to access the management interface.
(3) --name specifies the container name.
(4) --restart=always restart parameter, automatically restart the container when restarting docker.
(5) MINIO_ACCESS_KEY is to set the minio login name, no less than 3 characters; MINIO_SECRET_KEY is to set the minio login password, no less than 8 characters.
(6) -v specifies the mounting directory, before ":" is the host directory, and after ":" is the directory in the container. The files uploaded by minio are stored in the /data directory in the container by default. If they are not mounted to the host Host, deleting the container will delete the files . If the storage directory is mounted to the host, deleting the container will not delete the files in the host's mounting directory.
(7) --console-address specifies the client port; -address specifies the server port.
3. Test access
Visit http://ip:9090. If the login page appears, the deployment is successful.
4. Storage migration
The mount specified by -v is an absolute path, and the default is to mount to the root directory. After the service has been running for a period of time, uploading files takes up a lot of resources, causing other services to fail to run normally, and the storage directory needs to be migrated.
1. View the mounting directory
(1) View container id
docker ps
As shown in the figure, the first column is the container ID, and the second column is the container name.
(2) Check the mounting path
docker inspect 4e8450e2f9e3 | grep Mounts -A 20
As shown in the picture, it is the mounted host directory. The next thing to be copied is this directory.
2.Copy files
Copy the files in the original storage path of the host to the new storage path.
/mydata/minio/data is the original path, /home/mydata/minio/data is the new path
cp -r /mydata/minio/data /home/mydata/minio/data
3. Delete the original container, create and start a new container
(1) Stop the container
docker stop 容器ID
(2) Delete container
docker rm 容器ID
(3) Create and start a new container
Use the command introduced in the second section to create and start a new container. Pay attention to changing the mounting directory to the new directory where the file is stored.
After the container is started successfully, you can log in to the management interface for verification. At this point, the migration is complete.