Previously, storing Markdown images in a local folder can lead to a bloated directory over time, with a lot of space taken up by images. Synchronizing becomes very time-consuming, and when uploading to online platforms, local images won't be uploaded automatically; they still need to be handled and uploaded one by one manually. However, if the images are stored in the cloud, you only need to save a URL locally for previewing, and it will 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 is sold by cloud providers like Alibaba Cloud. 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, which can be from Alibaba Cloud or Tencent Cloud. 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's data, and you can choose where to place it according to 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 former is for the service backend, and the latter is for the client, which is the API access port.
-v ~/minio/data:/data
should be adjusted if your created directory is different.
-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 complete, you can access it directly by using ip:9000
to enter the backend and log in with the username and password you just set.
After logging in, creating Buckets and Access Keys is similar to operations in a regular OSS backend, and you can manually upload files.
Now, you need to fill in these configurations in a client software (in this case, our Markdown note software) so that you don’t have to use a browser to upload files.
4. Domain Name#
Currently, the returned image links use ip+port as the host. If you find this 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 you to access the stored files using the HTTPS protocol.