Provisioning Docker and Infrastructure Services on Alibaba Cloud ECS
Container Engine Setup
Begin by installing prerequisite utilities and configuring the official repository. Modern Alibaba Cloud ECS instances typically utilize dnf for package management.
sudo dnf install -y dnf-utils
sudo dnf config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo dnf install -y docker-ce docker-ce-cli containerd.io
sudo systemctl enable --now docker
To optimize image pull speeds, configure a private registry mirror through the Docker daemon.
sudo mkdir -p /etc/docker
cat <<EOF | sudo tee /etc/docker/daemon.json
{
"registry-mirrors": ["https://custom-alias.mirror.aliyuncs.com"]
}
EOF
sudo systemctl restart docker
Note that public cloud registries may lag behind upstream releases. To deploy newer versions (e.g., Redis 7.x), pull the image locally using Docker Desktop, export the archive, transfer it to the cloud instance, and import it.
Image Archival and Transfer
Manage container images across environments using standard export and load procedures.
# Export a specific tag to a tarball
docker save --output cache-archive.tar namespace/redis:latest
# After transferring the file via SCP or SFTP to the remote host
docker load --input cache-archive.tar
docker image ls --format "table {{.Repository}}\t{{.Tag}}"
Core Infrastructure Maintenance
Keep the host operating system secure and updated with standard package management commands.
sudo dnf upgrade -y
Redis Cache Deployment
Establish persistent directories for configuration and data before launching the container.
mkdir -p /opt/cache-stack/{config,volume}
# Place your customized redis.conf inside /opt/cache-stack/config/
Launch the container with port remapping, automatic restart policies, and volume mounts for persistence.
docker run -d --name redis-primary \
--restart unless-stopped \
-p 6380:6379 \
-v /opt/cache-stack/config/redis.conf:/etc/redis/redis.conf \
-v /opt/cache-stack/volume:/data \
redis:7.2 \
redis-server /etc/redis/redis.conf
Data Restoration via RDB Replace the dump file while the service is inactive to apply backups.
docker stop redis-primary
cp /path/to/backup/dump.rdb /opt/cache-stack/volume/
docker start redis-primary
Version Verification
docker exec -it redis-primary bash
redis-cli --version
Relational Database Operations
Initialize a MySQL instance with enviroment variable authentication and dynamic port assignment.
docker run -d --name db-engine \
--restart unless-stopped \
-p 3307:3306 \
-e MYSQL_ROOT_PASSWORD=SecureRootPass123! \
mysql:8.0
Interactive Management Access the running shell for command-line administration.
docker exec -it db-engine /bin/bash
mysql -u root -p
Schema Import Workflow Transfer a SQL dump into the container and execute it directly via the client.
docker cp /local/path/backup_2024.sql db-engine:/tmp/import_target.sql
docker exec -it db-engine mysql -u root -p target_database < /tmp/import_target.sql
Web Administration Console
Install a browser-based system control panel for centralized management and cron scheduling.
Repository Method
cat > /etc/yum.repos.d/webmin.repo <<EOF
[Webmin]
name=Webmin Neutral Repository
baseurl=https://download.webmin.com/download/yum
enabled=1
gpgcheck=1
gpgkey=https://www.webmin.com/jcameron-key.asc
EOF
sudo dnf install -y webmin
sudo /usr/libexec/webmin/changepass.pl /etc/webmin root AdminNewPass
Archive Method
cd /tmp/installers
tar -xzf webmin-current.tar.gz
cd webmin-*
sudo ./setup.sh /opt/webmin
# Access interface securely via https://<ecs-ip>:10000