Previously, when writing Markdown images stored in a local folder, over time, the folder would become quite bloated, with a lot of space taken up by images. Synchronizing became very time-consuming, and when uploading to online platforms, local images wouldn't be automatically uploaded; they still had to be processed and uploaded one by one manually. However, if stored in the cloud, only a URL needs to be saved locally for previewing, and it can be compatible across various platforms, instead of displaying a meaningless local path.
So I tried to upload the images from my notes to the cloud, ideally with automatic uploads when pasting. In fact, both typora and obsidian that I use have this feature, but they require OSS (Object Storage), which cloud providers like Alibaba Cloud sell. But do I really need to spend money on OSS when I have my own server?
Thus, I looked for an open-source OSS platform to set up and found minio, which is very powerful and easy to set up using Docker.
1. Preparation#
First, you need a cloud server/VPS; Alibaba Cloud or Tencent Cloud will work. If you don't have one, you can check my recommendation for a cost-effective option abroad: https://www.stmoonar.me/?p=6
Then install Docker
curl -fsSL https://get.docker.com | bash -s docker
2. Docker Deployment#
Next, create a directory to store MinIO data; you can choose where to place it based on your needs:
mkdir -p ~/minio/data
Now you can directly start the container
docker run \
-p 9000:9000 \
-p 9001:9001 \
--name minio \
-v ~/minio/data:/data \
-e "MINIO_ROOT_USER=ROOTNAME" \
-e "MINIO_ROOT_PASSWORD=CHANGEME123" \
quay.io/minio/minio server /data --console-address ":9001"
-p 9000:9000 -p 9001:9001
maps the container ports to the server ports; the first is for the service backend, and the second is for the client, which is the API access port.
-v ~/minio/data:/data
should be modified if it differs from the directory you created.
-e "MINIO_ACCESS_KEY=minioadmin"
is the username, and -e "MINIO_SECRET_KEY=minioadmin"
is the password; modify these two fields manually.
3. Access#
Once the previous step is completed, we can access it directly using ip:9000
to enter the backend, and log in with the username and password set earlier.
After logging in, creating Buckets and Access Keys is similar to operations in a typical OSS backend, and you can manually upload files.
Now, you just need to fill in these configurations in a client software (in this case, our Markdown note software), and you won't need to use a browser to upload files.
4. Domain Name#
Currently, the returned image links use ip+port as the host. If you find it unattractive and want to use your own domain name, you need to set up a reverse proxy in the nginx configuration file to proxy the domain resolved by DNS to port 9001.
You can also further configure an SSL certificate, allowing access to stored files via the HTTPS protocol.