Installing RustFS with Docker
RustFS is a high-performance, 100% S3-compatible open-source distributed object storage system. In single-node single-disk (SNSD) deployment mode, the backend uses zero erasure coding without additional data redundancy, suitable for local testing and small-scale scenarios. This article is based on RustFS official Linux binary packages, packaging RustFS and its runtime environment into containers through custom Dockerfile, and configuring data volumes and environment variables for one-click service startup.
1. Prerequisites
- Host Requirements
- Docker installed (≥ 20.10) and able to pull images and run containers normally
- Local path
/mnt/rustfs/data
(or custom path) for mounting object data
- Network and Firewall
- Ensure host port 9000 is open to external access (or consistent with custom port)
- Configuration File Preparation
- Define listening port, admin account, data path, etc. in host
/etc/rustfs/config.toml
(see Section 4 for details)
2. Quick Pull of RustFS Official Image
Use official Ubuntu base image to quickly pull RustFS official image:
docker pull rustfs/rustfs
3. Write Environment Configuration
Create configuration file /etc/rustfs/config.toml
on the host, example content:
RUSTFS_ACCESS_KEY=rustfsadmin
RUSTFS_SECRET_KEY=rustfsadmin
RUSTFS_VOLUMES="/data/rustfs{0...3}"
RUSTFS_ADDRESS=":9000"
#RUSTFS_SERVER_DOMAINS="play.rustfs.com:7000"
RUSTFS_CONSOLE_ENABLE=true
RUSTFS_OBS_ENDPOINT=""
RUSTFS_TLS_PATH="/opt/tls"
Note: For configuration item format and default values, please refer to official Linux installation documentation.
4. Run RustFS Container
RustFS SNSD Docker running method, combining the above image and configuration, execute:
docker run -d \
--name rustfs_local \
-p 9000:9000 \
-v /mnt/rustfs/data:/data \
rustfs/rustfs:latest \
/data
Parameter descriptions:
-p 9000:9000
: Map host port 9000 to container-v /mnt/rustfs/data:/data
: Mount data volume--name rustfs_local
: Custom container name-d
: Run in background
Complete Parameter Configuration Example
docker run -d \
--name rustfs_container \
-p 9000:9000 \
-v /mnt/rustfs/data:/data \
-e RUSTFS_ACCESS_KEY=rustfsadmin \
-e RUSTFS_SECRET_KEY=rustfsadmin \
-e RUSTFS_CONSOLE_ENABLE=true \
-e RUSTFS_SERVER_DOMAINS=example.com \
rustfs/rustfs:latest \
--address :9000 \
--console-enable \
--server-domains example.com \
--access-key rustfsadmin \
--secret-key rustfsadmin \
/data
Parameter Description and Corresponding Methods
Environment Variable Method (Recommended):
bash-e RUSTFS_ADDRESS=:9000 \ -e RUSTFS_SERVER_DOMAINS=example.com \ -e RUSTFS_ACCESS_KEY=rustfsadmin \ -e RUSTFS_SECRET_KEY=rustfsadmin \ -e RUSTFS_CONSOLE_ENABLE=true \
Command Line Parameter Method:
--address :9000 \ --server-domains example.com \ --access-key rustfsadmin \ --secret-key rustfsadmin \ --console-enable \
Required Parameters:
<VOLUMES>
: Specify at the end of command, such as/data
Common Configuration Combinations
Basic Configuration:
bashdocker run -d \ -p 9000:9000 \ -v /mnt/data:/data \ rustfs/rustfs:latest \ /data
Enable Console:
bashdocker run -d \ -p 9000:9000 \ -v /mnt/data:/data \ -e RUSTFS_CONSOLE_ENABLE=true \ rustfs/rustfs:latest \ ./target/debug/rustfs \ --console-enable \ /data
Custom Authentication Keys:
bashdocker run -d \ -p 9000:9000 \ -v /mnt/data:/data \ -e RUSTFS_ACCESS_KEY=rustfsadmin \ -e RUSTFS_SECRET_KEY=rustfsadmin \ rustfs/rustfs:latest \ ./target/debug/rustfs \ --access-key rustfsadmin \ --secret-key rustfsadmin \ /data
Important Notes
Port mapping must correspond:
- Service port defaults to 9000 (
-p 9000:9000
)
- Service port defaults to 9000 (
Data volumes must be persistent:
-v /host/path:/container/path
Environment variables and command line parameters can be mixed, but command line parameters have higher priority
If using TLS, additional certificate path mounting is needed:
bash-v /path/to/certs:/certs \ -e RUSTFS_TLS_PATH=/certs \
5. Verification and Access
- View Container Status and Logs:
docker logs rustfs_local
Logs should show successful service startup and listening on port 9000.
- Test S3 API:
Use mc
or other S3 clients:
mc alias set rustfs http://localhost:9000 rustfsadmin ChangeMe123!
mc mb rustfs/mybucket
mc ls rustfs
If buckets can be successfully created and listed, deployment is effective.
6. Other Recommendations
- Production Environment Recommendations:
- Use multi-node deployment architecture
- Enable TLS encrypted communication
- Configure log rotation strategy
- Set up regular backup strategy
- Storage Recommendations:
- Use local SSD/NVMe storage
- Avoid using network file systems (NFS)
- Ensure storage directory exclusive access
Summary
This article combines RustFS single-node single-disk containerization best practices, demonstrating in detail how to build RustFS images through Docker and deploy SNSD environments. This solution is easy to quickly start and experiment with, and can later be extended to multi-node multi-disk production-level clusters on platforms like Kubernetes, Swarm, etc. using the same approach.